[c++] lambda递归

/ 3,088评论 / 10521阅读 / 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. Waynetar说道:

    buying prescription drugs in mexico online: best online pharmacies in mexico – mexican online pharmacies prescription drugs

  2. Thank you for the auspicious writeup It in fact was a amusement account it Look advanced to more added agreeable from you By the way how could we communicate

  3. DominicHOr说道:

    mexican border pharmacies shipping to usa: buying prescription drugs in mexico – mexico drug stores pharmacies

  4. Waynetar说道:

    buying from online mexican pharmacy: mexican rx online – medication from mexico pharmacy

  5. Madalyn Lemke说道:

    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!

  6. Arnoldscava说道:

    medication from mexico pharmacy best online pharmacies in mexico mexican mail order pharmacies

  7. DominicHOr说道:

    medication from mexico pharmacy: medication from mexico pharmacy – mexico drug stores pharmacies

  8. NelsonSaIlk说道:

    mexico pharmacies prescription drugs: mexico drug stores pharmacies – mexico pharmacies prescription drugs

  9. NelsonSaIlk说道:

    reputable mexican pharmacies online: pharmacies in mexico that ship to usa – buying prescription drugs in mexico

  10. Arnoldscava说道:

    mexico drug stores pharmacies best online pharmacies in mexico mexico pharmacies prescription drugs

  11. Waynetar说道:

    medicine in mexico pharmacies: reputable mexican pharmacies online – best online pharmacies in mexico

  12. DominicHOr说道:

    mexico pharmacies prescription drugs: purple pharmacy mexico price list – mexican online pharmacies prescription drugs

  13. Waynetar说道:

    mexican mail order pharmacies: buying prescription drugs in mexico – mexico drug stores pharmacies

  14. Arnoldscava说道:

    mexico pharmacy mexican pharmaceuticals online purple pharmacy mexico price list

  15. DominicHOr说道:

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

  16. NelsonSaIlk说道:

    pharmacies in mexico that ship to usa: medication from mexico pharmacy – mexican drugstore online

  17. NelsonSaIlk说道:

    mexican rx online: reputable mexican pharmacies online – buying from online mexican pharmacy

  18. Arnoldscava说道:

    mexico pharmacy buying from online mexican pharmacy purple pharmacy mexico price list

  19. Waynetar说道:

    mexico drug stores pharmacies: medicine in mexico pharmacies – mexico pharmacies prescription drugs

  20. DominicHOr说道:

    mexico drug stores pharmacies: purple pharmacy mexico price list – best online pharmacies in mexico

  21. Waynetar说道:

    buying prescription drugs in mexico online: best online pharmacies in mexico – pharmacies in mexico that ship to usa

  22. DominicHOr说道:

    best online pharmacies in mexico: reputable mexican pharmacies online – medication from mexico pharmacy

  23. Arnoldscava说道:

    buying from online mexican pharmacy mexico pharmacy mexico drug stores pharmacies

  24. NelsonSaIlk说道:

    mexico drug stores pharmacies: buying prescription drugs in mexico online – mexico drug stores pharmacies

  25. Arnoldscava说道:

    mexican drugstore online mexican rx online buying prescription drugs in mexico online

  26. Waynetar说道:

    reputable mexican pharmacies online: п»їbest mexican online pharmacies – mexican border pharmacies shipping to usa

  27. DominicHOr说道:

    purple pharmacy mexico price list: mexico drug stores pharmacies – medication from mexico pharmacy

  28. Waynetar说道:

    mexico drug stores pharmacies: mexican border pharmacies shipping to usa – buying from online mexican pharmacy

  29. DominicHOr说道:

    mexico drug stores pharmacies: mexico drug stores pharmacies – mexican pharmaceuticals online

  30. Arnoldscava说道:

    mexico pharmacy purple pharmacy mexico price list best online pharmacies in mexico

  31. NelsonSaIlk说道:

    mexico drug stores pharmacies: mexican border pharmacies shipping to usa – mexico drug stores pharmacies

  32. NelsonSaIlk说道:

    mexico drug stores pharmacies: best online pharmacies in mexico – mexican online pharmacies prescription drugs

  33. Wow amazing blog layout How long have you been blogging for you made blogging look easy The overall look of your web site is magnificent as well as the content

  34. Arnoldscava说道:

    mexico drug stores pharmacies mexican online pharmacies prescription drugs buying from online mexican pharmacy

  35. RichardMonge说道:

    http://mexicandeliverypharma.com/# mexican pharmaceuticals online

  36. Waynetar说道:

    mexico drug stores pharmacies: mexican pharmaceuticals online – mexico drug stores pharmacies

  37. DominicHOr说道:

    mexican drugstore online: reputable mexican pharmacies online – pharmacies in mexico that ship to usa

  38. Waynetar说道:

    mexican drugstore online: mexican rx online – mexican rx online

  39. DominicHOr说道:

    mexican online pharmacies prescription drugs: buying from online mexican pharmacy – mexico drug stores pharmacies

  40. Arnoldscava说道:

    mexican border pharmacies shipping to usa mexico pharmacies prescription drugs mexican mail order pharmacies

  41. RichardMonge说道:

    https://mexicandeliverypharma.online/# п»їbest mexican online pharmacies

  42. NelsonSaIlk说道:

    mexican online pharmacies prescription drugs: buying prescription drugs in mexico – best online pharmacies in mexico

  43. NelsonSaIlk说道:

    medicine in mexico pharmacies: reputable mexican pharmacies online – mexico pharmacies prescription drugs

  44. Arnoldscava说道:

    best online pharmacies in mexico best online pharmacies in mexico buying from online mexican pharmacy

  45. Waynetar说道:

    reputable mexican pharmacies online: pharmacies in mexico that ship to usa – buying from online mexican pharmacy

  46. DominicHOr说道:

    medicine in mexico pharmacies: buying from online mexican pharmacy – mexican border pharmacies shipping to usa

  47. Waynetar说道:

    medicine in mexico pharmacies: buying prescription drugs in mexico online – purple pharmacy mexico price list

  48. DominicHOr说道:

    mexican drugstore online: mexican drugstore online – mexican border pharmacies shipping to usa

  49. Arnoldscava说道:

    pharmacies in mexico that ship to usa п»їbest mexican online pharmacies pharmacies in mexico that ship to usa

  50. NelsonSaIlk说道:

    buying prescription drugs in mexico: mexican border pharmacies shipping to usa – buying prescription drugs in mexico online

发表回复

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