Created
February 19, 2024 19:27
-
-
Save superwills/0683895314c7d7831b077e39aff21d45 to your computer and use it in GitHub Desktop.
Revisions
-
superwills created this gist
Feb 19, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ #include <stdio.h> int main(int argc, const char * argv[]) { struct FirstRun { bool hasRun = 0; operator bool() { bool firstRun = !hasRun; hasRun = 1; return firstRun; } }; for (int i = 0; i < 3; i++) { static FirstRun isFirstRun; if (isFirstRun) puts("1st run"); else puts("subsequent"); } return 0; }