[c++] lambda递归

/ 3,096评论 / 10556阅读 / 0点赞

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递归

int main() {
    auto fun = [&fun](int value) {
        if(value < 0) { 
             return;
        }
        cout << value << endl;
        // 这里是不行的!!!
        fun(value - 1);
    };
    fun(10);
    return 0;
}

#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;
}
  1. Leonardskarm说道:

    https://edpillpharmacy.store/# ed medicines online

  2. Leonardskarm说道:

    https://edpillpharmacy.store/# cheapest ed pills

  3. Tints of colors are made by adding white (e.g., red-orange plus white gives us coral).

  4. Douglasnug说道:

    mexican pharmaceuticals online: Mexico pharmacy online – mexican mail order pharmacies

  5. onbet说道:

    Hi there! This blog post could not be written much better! Looking at this article reminds me of my previous roommate! He always kept talking about this. I most certainly will forward this article to him. Fairly certain he’s going to have a very good read. Thanks for sharing!

  6. Hoxsin Bussan Co., Ltd.

  7. With this in mind, economic development is typically associated with improvements in a variety of areas or indicators (such as literacy rates, life expectancy, and poverty rates), that may be causes of economic development rather than consequences of specific economic development programs.

  8. convertidor mp3说道:

    Hello! I simply would like to give you a big thumbs up for your great info you have right here on this post. I am coming back to your site for more soon.

  9. 78win说道:

    Very good post. I am going through some of these issues as well..

  10. Douglasnug说道:

    mexican pharmaceuticals online: п»їbest mexican online pharmacies – mexico drug stores pharmacies

  11. bizzlyn说道:

    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

  12. Douglasnug说道:

    indian pharmacies safe: Indian pharmacy international shipping – buy prescription drugs from india

  13. Leonardskarm说道:

    http://indiapharmacy.shop/# Online medicine order

  14. Leonardskarm说道:

    https://mexicopharmacy.win/# mexico pharmacies prescription drugs

  15. Hi, I do think this is an excellent website. I stumbledupon it 😉 I may return once again since I book-marked it. Money and freedom is the greatest way to change, may you be rich and continue to guide other people.

  16. Hi! I just wish to offer you a huge thumbs up for your great information you have here on this post. I will be coming back to your website for more soon.

  17. Douglasnug说道:

    top 10 pharmacies in india: Cheapest online pharmacy – Online medicine order

  18. Douglasnug说道:

    best online pharmacies in mexico: Best online Mexican pharmacy – mexican border pharmacies shipping to usa

  19. I really love your website.. Great colors & theme. Did you create this amazing site yourself? Please reply back as I’m trying to create my very own blog and would love to find out where you got this from or exactly what the theme is named. Cheers!

  20. Hello there, I think your web site might be having internet browser compatibility problems. When I take a look at your blog in Safari, it looks fine however, when opening in I.E., it’s got some overlapping issues. I simply wanted to provide you with a quick heads up! Besides that, fantastic website!

  21. Having read this I thought it was really informative. I appreciate you taking the time and effort to put this information together. I once again find myself spending way too much time both reading and leaving comments. But so what, it was still worthwhile!

  22. Leonardskarm说道:

    http://indiapharmacy.shop/# buy prescription drugs from india

  23. Douglasnug说道:

    indianpharmacy com: Cheapest online pharmacy – online pharmacy india

  24. Leonardskarm说道:

    http://mexicopharmacy.win/# medicine in mexico pharmacies

  25. Douglasnug说道:

    discount ed meds: Cheap ED pills online – best online ed treatment

  26. download youtube说道:

    I seriously love your website.. Pleasant colors & theme. Did you build this amazing site yourself? Please reply back as I’m planning to create my very own site and want to learn where you got this from or what the theme is called. Appreciate it!

  27. blogmedia说道:

    É como se você lesse minha mente Você parece saber muito sobre isso, como se você tivesse escrito o livro nele ou algo assim. Acho que você pode fazer com algumas fotos para transmitir um pouco a mensagem, mas fora isso, este é um blog fantástico. ótima leitura, certamente voltarei

  28. Douglasnug说道:

    best ed meds online: Cheapest online ED treatment – erectile dysfunction medications online

  29. Douglasnug说道:

    top online pharmacy india: Top online pharmacy in India – indian pharmacies safe

  30. Leonardskarm说道:

    https://edpillpharmacy.store/# online ed drugs

  31. Post Escort Ads说道:

    Hi! I could have sworn I’ve visited this site before but after going through many of the articles I realized it’s new to me. Regardless, I’m definitely delighted I stumbled upon it and I’ll be bookmarking it and checking back regularly.

  32. Leonardskarm说道:

    http://mexicopharmacy.win/# mexican drugstore online

  33. Excellent site you have got here.. It’s difficult to find quality writing like yours nowadays. I honestly appreciate individuals like you! Take care!!

  34. However, each client is different and has unique needs when it comes to portfolio management, and this is where Strategic Wealth Management from Santa Barbara comes through in spades.

  35. Douglasnug说道:

    cost of ed meds: online ed prescription same-day – buying ed pills online

  36. Douglasnug说道:

    mexico drug stores pharmacies: mexico pharmacy win – mexican drugstore online

  37. The very next time I read a blog, Hopefully it doesn’t fail me just as much as this particular one. I mean, I know it was my choice to read through, nonetheless I genuinely thought you would have something useful to talk about. All I hear is a bunch of complaining about something that you could possibly fix if you were not too busy searching for attention.

  38. Tonic Greens说道:

    I’ve read a few excellent stuff here. Certainly value bookmarking for revisiting. I surprise how a lot attempt you place to create one of these fantastic informative web site.

  39. It’s really a great and helpful piece of information. I am glad that you shared this helpful information with us. Please keep us informed like this. Thank you for sharing.

  40. For example, a long-term goal would be to “retire at age 65 with a personal net worth of $1,000,000”, while a short-term goal would be to “save up for a new computer in the next month.” Setting financial goals helps to direct financial planning by determining the parameters and expectations one aims to achieve.

  41. LEANBIOME说道:

    Loved this article. It’s very comprehensive and filled with useful details. Excellent work!

  42. This article is amazing! Filled with useful insights and extremely clear. Thank you for sharing this.

  43. Douglasnug说道:

    cheap ed medicine: online ed medicine – affordable ed medication

  44. Douglasnug说道:

    ed medications cost: Best ED pills non prescription – best online ed meds

  45. 戸田 漁港说道:

    These future profits also have to be discounted to their present value.

  46. The nominal value of the contract would be $44,450 (5,000 bushels x $8.89).

  47. Professionals present data or information in a maze of rows and columns.

  48. Older issues have names such as “Treasury Stock” and newer issues are called “Treasury Gilt”.

  49. vevo 株価说道:

    Phishers plan, set up and execute attacks to steal personal and financial data, often using deceptive tactics like spoofed email addresses and obfuscated links.

  50. Leonardskarm说道:

    http://mexicopharmacy.win/# buying prescription drugs in mexico

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注