fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #include <memory>
  5. #include <type_traits>
  6.  
  7. //class Manager;
  8.  
  9. class Game
  10. {
  11. public:
  12. enum class State
  13. {
  14. MAIN_MENU = 0x00000001,
  15. PLAY = 0x00000002,
  16. PAUSE = 0x00000004,
  17. };
  18.  
  19. static Game& Instance()
  20. {
  21. static Game sGame;
  22. return sGame;
  23. }
  24.  
  25. void Run();
  26.  
  27. void SetState(State state);
  28.  
  29. private:
  30. //Game();
  31. //~Game() = default;
  32.  
  33. State mState = State::MAIN_MENU;
  34. //std::unique_ptr<Manager> mManager;// = nullptr;
  35. };
  36.  
  37. inline Game::State operator|(Game::State lhs, Game::State rhs)
  38. {
  39. using type = std::underlying_type<Game::State>::type;
  40. return static_cast<Game::State>(static_cast<type>(lhs) | static_cast<type>(rhs));
  41. }
  42.  
  43. inline Game::State operator&(Game::State lhs, Game::State rhs)
  44. {
  45. using type = std::underlying_type<Game::State>::type;
  46. return static_cast<Game::State>(static_cast<type>(lhs) & static_cast<type>(rhs));
  47. }
  48.  
  49. int main() {
  50. // your code goes here
  51. return 0;
  52. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/4.9/type_traits:35:0,
                 from prog.cpp:5:
/usr/include/c++/4.9/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
prog.cpp:12:5: warning: scoped enums only available with -std=c++11 or -std=gnu++11
     enum class State
     ^
prog.cpp:33:27: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
     State mState = State::MAIN_MENU;
                           ^
prog.cpp:33:20: error: 'State' is not a class or namespace
     State mState = State::MAIN_MENU;
                    ^
prog.cpp: In function 'Game::State operator|(Game::State, Game::State)':
prog.cpp:39:11: error: expected nested-name-specifier before 'type'
     using type = std::underlying_type<Game::State>::type;
           ^
prog.cpp:40:49: error: 'type' does not name a type
     return static_cast<Game::State>(static_cast<type>(lhs) | static_cast<type>(rhs));
                                                 ^
prog.cpp:40:74: error: 'type' does not name a type
     return static_cast<Game::State>(static_cast<type>(lhs) | static_cast<type>(rhs));
                                                                          ^
prog.cpp: In function 'Game::State operator&(Game::State, Game::State)':
prog.cpp:45:11: error: expected nested-name-specifier before 'type'
     using type = std::underlying_type<Game::State>::type;
           ^
prog.cpp:46:49: error: 'type' does not name a type
     return static_cast<Game::State>(static_cast<type>(lhs) & static_cast<type>(rhs));
                                                 ^
prog.cpp:46:74: error: 'type' does not name a type
     return static_cast<Game::State>(static_cast<type>(lhs) & static_cast<type>(rhs));
                                                                          ^
stdout
Standard output is empty