Mercurial > dwindows
comparison dw.hpp @ 2870:7b4e30c19757
C++: Disable singleton safety code for non C++11 compilers.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 18 Dec 2022 13:33:22 +0000 |
parents | c873b6f862b9 |
children | 4b7c4cd7a11d |
comparison
equal
deleted
inserted
replaced
2869:c873b6f862b9 | 2870:7b4e30c19757 |
---|---|
115 { | 115 { |
116 protected: | 116 protected: |
117 App() { } | 117 App() { } |
118 static App *_app; | 118 static App *_app; |
119 public: | 119 public: |
120 // Allow the code to compile if handicapped on older compilers | |
121 #if __cplusplus >= 201103L | |
120 // Singletons should not be cloneable. | 122 // Singletons should not be cloneable. |
121 App(App &other) = delete; | 123 App(App &other) = delete; |
122 // Singletons should not be assignable. | 124 // Singletons should not be assignable. |
123 void operator=(const App &) = delete; | 125 void operator=(const App &) = delete; |
126 #endif | |
124 // Initialization functions for creating App | 127 // Initialization functions for creating App |
125 static App *Init() { if(!_app) { _app = new App; dw_init(TRUE, 0, NULL); } return _app; } | 128 static App *Init() { if(!_app) { _app = new App; dw_init(TRUE, 0, NULL); } return _app; } |
126 static App *Init(const char *appid) { if(!_app) { _app = new App(); dw_app_id_set(appid, NULL); dw_init(TRUE, 0, NULL); } return _app; } | 129 static App *Init(const char *appid) { if(!_app) { _app = new App(); dw_app_id_set(appid, NULL); dw_init(TRUE, 0, NULL); } return _app; } |
127 static App *Init(const char *appid, const char *appname) { if(!_app) { _app = new App(); dw_app_id_set(appid, appname); dw_init(TRUE, 0, NULL); } return _app; } | 130 static App *Init(const char *appid, const char *appname) { if(!_app) { _app = new App(); dw_app_id_set(appid, appname); dw_init(TRUE, 0, NULL); } return _app; } |
128 static App *Init(int argc, char *argv[]) { if(!_app) { _app = new App(); dw_init(TRUE, argc, argv); } return _app; } | 131 static App *Init(int argc, char *argv[]) { if(!_app) { _app = new App(); dw_init(TRUE, argc, argv); } return _app; } |