fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5. #define DBG(x) cout << left << setw(30) << #x << boolalpha << (x) << endl;
  6.  
  7. struct CApp;
  8.  
  9. template<typename T = CApp>
  10. struct CThread
  11. {
  12.  
  13. void run(){
  14. while(T::Running){
  15. DBG(T::Running);
  16. T::Running = false;
  17. DBG(T::Running);
  18. }
  19. }
  20.  
  21. };
  22.  
  23. struct CApp
  24. {
  25. static bool Running;
  26. CThread<CApp> t;
  27. };
  28.  
  29. bool CApp::Running = true;
  30.  
  31. int main(void)
  32. {
  33. CApp ca;
  34.  
  35. DBG(CApp::Running);
  36. ca.t.run();
  37. DBG(CApp::Running);
  38.  
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
CApp::Running                 true
T::Running                    true
T::Running                    false
CApp::Running                 false