Created
December 21, 2017 00:23
-
-
Save mtao/4a9cfc5f08130578ccbe1fb65fb71eee to your computer and use it in GitHub Desktop.
if (and presumably for) can have static variables in initialization. test is due to me trying to not pollute my namespaces with static variables with imgui Raw
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
#include <iostream> | |
void run() { | |
if(static bool f = false; f) { | |
std::cout << "true!" << std::endl; | |
f = false; | |
} else { | |
std::cout << "false!" << std::endl; | |
f = true; | |
} | |
} | |
int main() { | |
run(); | |
run(); | |
run(); | |
run(); | |
run(); | |
return 0; | |
} | |
/* | |
Example usage stolen from Imgui examples: | |
if (static bool show_another_window = false; show_another_window) | |
{ | |
ImGui::Begin("Another Window", &show_another_window); | |
ImGui::Text("Hello from another window!"); | |
ImGui::End(); | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment