[c++] lambda递归

/ 4,495评论 / 13044阅读 / 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. Having read this I thought it was rather enlightening. I appreciate you taking the time and energy to put this information together. I once again find myself spending a significant amount of time both reading and leaving comments. But so what, it was still worthwhile!

  2. best vpn说道:

    You’re so cool! I don’t think I have read a single thing like that before. So great to discover another person with some original thoughts on this subject matter. Really.. thank you for starting this up. This web site is something that is needed on the internet, someone with some originality.

  3. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  4. best VPN 2025说道:

    Having read this I thought it was really informative. I appreciate you finding the time and energy to put this article together. I once again find myself personally spending a lot of time both reading and posting comments. But so what, it was still worth it!

  5. LarryHer说道:

    the best ed pills: Canada pharmacy – best cure for ed

  6. Phim sex cưỡng hiếp trẻ em

  7. It’s hard to find experienced people about this topic, but you seem like you know what you’re talking about! Thanks

  8. Jamiescact说道:

    https://canadiandrugsgate.com/# ed prescription drugs

  9. pgslotauto说道:

    Good write-up. I certainly appreciate this website. Keep writing!

  10. Everything is very open with a precise description of the challenges. It was truly informative. Your site is very useful. Many thanks for sharing.

  11. Bradleyarrip说道:

    https://canadiandrugsgate.com/# ed medications comparison

  12. Bradleyarrip说道:

    http://indianpharmacyeasy.com/# indian pharmacy online

  13. Тут можно преобрести сейфы для оружия пистолетные оружейный сейф на заказ москва

  14. Тут можно преобрести сейф для оружия купить сейф для оружия цены

  15. profi-teh-remont说道:

    Сервисный центр предлагает замена акб prestigio muze a3 заменить заднюю крышку prestigio muze a3

  16. profi-teh-remont说道:

    Сервисный центр предлагает ремонт wexler tab 700 цены ремонт wexler tab 700 цены

  17. Pretty! This has been an incredibly wonderful post. Many thanks for providing this information.

  18. GlennSeade说道:

    buying prescription drugs in mexico online Mexican Pharm Gate purple pharmacy mexico price list

  19. Excellent write-up. I definitely appreciate this website. Thanks!

  20. Тут можно преобрести купить сейф оружейный в москве оружейный сейф для пистолета

  21. Тут можно преобрести шкаф оружейный купить купить сейф с доставкой в москве

  22. Jefferyswava说道:

    buying prescription drugs in mexico online: mexicanpharmgate.com – mexican mail order pharmacies

  23. Jamiescact说道:

    http://mexicanpharmgate.com/# mexico pharmacies prescription drugs

  24. LarryHer说道:

    best online pharmacies in mexico: mexico pharmacy – medicine in mexico pharmacies

  25. I’m impressed, I must say. Seldom do I encounter a blog that’s equally educative and entertaining, and let me tell you, you’ve hit the nail on the head. The issue is something too few people are speaking intelligently about. Now i’m very happy I came across this during my hunt for something relating to this.

  26. rebirth ro wiki说道:

    Hello there, I think your blog may be having browser compatibility problems. When I take a look at your website in Safari, it looks fine however, when opening in IE, it has some overlapping issues. I just wanted to give you a quick heads up! Other than that, wonderful site.

  27. Jefferyswava说道:

    amoxicillin without a doctor’s prescription: canadiandrugsgate – buy prescription drugs from india

  28. Тут можно преобрести огнестойкий сейф сейф огнестойкий купить

  29. Jamiescact说道:

    https://indianpharmacyeasy.com/# reputable indian pharmacies

  30. CNY Snacks说道:

    Wonderful post! We are linking to this great article on our website. Keep up the great writing.

  31. GlennSeade说道:

    mexican drugstore online MexicanPharmGate mexico drug stores pharmacies

  32. LarryHer说道:

    medication from mexico pharmacy: mexicanpharmgate.com – mexican rx online

  33. peach crafts说道:

    There are dome tents, frame tents, wall tents, and cabin tents.

  34. Тут можно преобрести сейф огнестойкий сейф жаростойкий

  35. Jamiescact说道:

    http://mexicanpharmgate.com/# buying from online mexican pharmacy

  36. Pretty! This was an extremely wonderful post. Many thanks for providing this info.

  37. I was more than happy to uncover this site. I wanted to thank you for your time for this wonderful read!! I definitely really liked every bit of it and i also have you book marked to check out new things on your site.

  38. Bradleyarrip说道:

    http://indianpharmacyeasy.com/# top online pharmacy india

  39. Bradleyarrip说道:

    https://canadiandrugsgate.com/# best non prescription ed pills

  40. Jamiescact说道:

    https://mexicanpharmgate.com/# mexican online pharmacies prescription drugs

  41. Jefferyswava说道:

    Online medicine home delivery: Online medicine home delivery – indian pharmacy paypal

  42. Jamiescact说道:

    http://canadiandrugsgate.com/# what is the best ed drug

  43. Jamiescact说道:

    https://mexicanpharmgate.com/# buying from online mexican pharmacy

  44. Jefferyswava说道:

    best erection pills: canadian pharmacy drugs gate – best natural cure for ed

  45. Тут можно преобрести купить сейф для оружия купить сейф для оружия

  46. Hi, There’s no doubt that your site might be having web browser compatibility problems. When I take a look at your site in Safari, it looks fine however when opening in IE, it’s got some overlapping issues. I just wanted to provide you with a quick heads up! Aside from that, excellent site.

  47. LarryHer说道:

    online ed medications: Canada pharmacy – natural ed treatment

发表回复

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