Created
January 30, 2019 08:34
-
-
Save sailfish009/97572e3d0e55028df7f34a20534fe71c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://stackoverflow.com/questions/7213839/equivalent-in-c-of-yield-in-c | |
https://ideone.com/SQZ1qZ | |
#include <iostream> | |
int main() | |
{ | |
auto&& function = []() | |
{ | |
int i = 0; return [=]() mutable { int arr[] = {1,2,4,8,16,16777216}; if ( i < 6 ) return arr[i++]; return 0; }; | |
}(); | |
for ( unsigned long i = 0; i != 10; ++i ) | |
std::cout << "\t" << function() << "\t|"; | |
std::cout << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment