title: Using a "using" expression to define a type brings up loads of random errors
body: <p>I am making an eventmanager for a game, but when I try to use the &quot;using&quot; expression to define some types, I get 15 random errors which don't make any sense and has nothing to do with the using expression.</p>
  <p>Here is the code WITH the using expressions:</p>
  <pre><code>#include &lt;SFML/Graphics.hpp&gt;
  #include &lt;unordered_map&gt;
  #include &lt;functional&gt;
  
  using Events = std::vector&lt;std::pair&lt;EventType, EventInfo&gt;&gt;;
  using Bindings = std::unordered_map&lt;std::string, Binding*&gt;;
  using Callbacks = std::unordered_map&lt;std::string,
      std::function&lt;void(EventDetails*)&gt;&gt;;
  
  class EventManager
  {
  };
  
  struct Binding {
      Binding(const std::string&amp; l_name)
          : m_name(l_name), m_details(l_name), c(0) {}
  
      void BindEvent(EventType l_type, EventInfo l_info = EventInfo())
      {
          m_events.emplace_back(l_type, l_info);
      }
  
      Events m_events;
      std::string m_name;
      int c; // Count of events that are &quot;happening&quot;.
      EventDetails m_details;
  };
  
  struct EventDetails {
      EventDetails(const std::string&amp; l_bindName)
          : m_name(l_bindName)
      {
          Clear();
      }
  
      std::string m_name;
      sf::Vector2i m_size;
      sf::Uint32 m_textEntered;
      sf::Vector2i m_mouse;
  
      int m_mouseWheelDelta;
      int m_keyCode; // Single key code.
  
      void Clear() {
          m_size = sf::Vector2i(0, 0);
          m_textEntered = 0;
          m_mouse = sf::Vector2i(0, 0);
          m_mouseWheelDelta = 0;
          m_keyCode = -1;
      }
  };
  
  struct EventInfo {
      EventInfo() { m_code = 0; }
      EventInfo(int l_event) { m_code = l_event; }
      union {
          int m_code;
      };
  };
  
  enum class EventType {
      KeyDown = sf::Event::KeyPressed,
      KeyUp = sf::Event::KeyReleased,
      MButtonDown = sf::Event::MouseButtonPressed,
      MButtonUp = sf::Event::MouseButtonReleased,
      MouseWheel = sf::Event::MouseWheelMoved,
      WindowResized = sf::Event::Resized,
      GainedFocus = sf::Event::GainedFocus,
      LostFocus = sf::Event::LostFocus,
      MouseEntered = sf::Event::MouseEntered,
      MouseLeft = sf::Event::MouseLeft,
      Closed = sf::Event::Closed,
      TextEntered = sf::Event::TextEntered,
      Keyboard = sf::Event::Count + 1, Mouse, Joystick
  };
  </code></pre>
  <p>Gives errors which don't make any sense:</p>
  <pre><code>Severity    Code    Description Project File    Line    Suppression State
  Error   C2065   'EventType': undeclared identifier  SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   5   
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C2065   'EventInfo': undeclared identifier  SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   5   
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C2923   'std::pair': 'EventType' is not a valid template type argument for parameter '_Ty1' SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   5   
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C2923   'std::pair': 'EventInfo' is not a valid template type argument for parameter '_Ty2' SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   5   
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C3203   'pair': unspecialized class template can't be used as a template argument for template parameter '_Ty', expected a real type    SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   5   
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C2065   'Binding': undeclared identifier    SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   6   
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C2059   syntax error: '&gt;'   SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   6   
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C2059   syntax error: ')'   SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   8   
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C4430   missing type specifier - int assumed. Note: C++ does not support default-int    SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   26  
  
  </code></pre>
  <p>And lots of other random errors...</p>
  <p>But when I make this change:</p>
  <pre><code>//using Events = std::vector&lt;std::pair&lt;EventType, EventInfo&gt;&gt;;
  //using Bindings = std::unordered_map&lt;std::string, Binding*&gt;;
  //using Callbacks = std::unordered_map&lt;std::string,
  //  std::function&lt;void(EventDetails*)&gt;&gt;;
  </code></pre>
  <p>I get these errors because the types don't exist (this is normal):</p>
  <pre><code>Severity    Code    Description Project File    Line    Suppression State
  Error (active)  E0020   identifier &quot;Events&quot; is undefined    SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   23  
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C2061   syntax error: identifier 'EventType'    SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   18  
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C3646   'm_events': unknown override specifier  SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   23  
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C4430   missing type specifier - int assumed. Note: C++ does not support default-int    SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   23  
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C3646   'm_details': unknown override specifier SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   26  
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C4430   missing type specifier - int assumed. Note: C++ does not support default-int    SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   26  
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C2614   'Binding': illegal member initialization: 'm_details' is not a base or member   SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   16  
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C2065   'm_events': undeclared identifier   SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   20  
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C2065   'l_type': undeclared identifier SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   20  
  
  Severity    Code    Description Project File    Line    Suppression State
  Error   C2065   'l_info': undeclared identifier SFML-EventManager   C:\Users\wout\source\repos\SFML-EventManager\SFML-EventManager\EventManager.h   20  
  
  </code></pre>
  <p>Any insight is appreciated!</p>
  <p>Edit:
  I placed the using statement under all referenced types, still get the same errors...</p>
  <pre><code>#include &lt;SFML/Graphics.hpp&gt;
  #include &lt;unordered_map&gt;
  #include &lt;functional&gt;
  
  class EventManager {
  public:
      EventManager();
      ~EventManager();
  
      bool AddBinding(Binding* l_binding);
      bool RemoveBinding(std::string l_name);
  
      void SetFocus(const bool&amp; l_focus);
  
      // Needs to be defined in the header!
      template&lt;class T&gt;
      bool AddCallback(const std::string&amp; l_name,
          void(T::* l_func)(EventDetails*), T* l_instance)
      {
          auto temp = std::bind(l_func, l_instance,
              std::placeholders::_1);
          return m_callbacks.emplace(l_name, temp).second;
      }
      void RemoveCallback(const std::string&amp; l_name) {
          m_callbacks.erase(l_name);
      }
  
      void HandleEvent(sf::Event&amp; l_event);
      void Update();
  
      sf::Vector2i GetMousePos(sf::RenderWindow* l_wind = nullptr) {
          return (l_wind ? sf::Mouse::getPosition(*l_wind)
              : sf::Mouse::getPosition());
      }
  private:
      void LoadBindings();
  
      Bindings m_bindings;
      Callbacks m_callbacks;
  
      bool m_hasFocus;
  };
  
  struct Binding {
      Binding(const std::string&amp; l_name)
          : m_name(l_name), m_details(l_name), c(0) {}
  
      void BindEvent(EventType l_type, EventInfo l_info = EventInfo())
      {
          m_events.emplace_back(l_type, l_info);
      }
  
      Events m_events;
      std::string m_name;
      int c; // Count of events that are &quot;happening&quot;.
      EventDetails m_details;
  };
  
  struct EventDetails {
      EventDetails(const std::string&amp; l_bindName)
          : m_name(l_bindName)
      {
          Clear();
      }
  
      std::string m_name;
      sf::Vector2i m_size;
      sf::Uint32 m_textEntered;
      sf::Vector2i m_mouse;
  
      int m_mouseWheelDelta;
      int m_keyCode; // Single key code.
  
      void Clear() {
          m_size = sf::Vector2i(0, 0);
          m_textEntered = 0;
          m_mouse = sf::Vector2i(0, 0);
          m_mouseWheelDelta = 0;
          m_keyCode = -1;
      }
  };
  
  struct EventInfo {
      EventInfo() { m_code = 0; }
      EventInfo(int l_event) { m_code = l_event; }
      union {
          int m_code;
      };
  };
  
  enum class EventType {
      KeyDown = sf::Event::KeyPressed,
      KeyUp = sf::Event::KeyReleased,
      MButtonDown = sf::Event::MouseButtonPressed,
      MButtonUp = sf::Event::MouseButtonReleased,
      MouseWheel = sf::Event::MouseWheelMoved,
      WindowResized = sf::Event::Resized,
      GainedFocus = sf::Event::GainedFocus,
      LostFocus = sf::Event::LostFocus,
      MouseEntered = sf::Event::MouseEntered,
      MouseLeft = sf::Event::MouseLeft,
      Closed = sf::Event::Closed,
      TextEntered = sf::Event::TextEntered,
      Keyboard = sf::Event::Count + 1, Mouse, Joystick
  };
  
  using Events = std::vector&lt;std::pair&lt;EventType, EventInfo&gt;&gt;;
  using Bindings = std::unordered_map&lt;std::string, Binding*&gt;;
  using Callbacks = std::unordered_map&lt;std::string,
      std::function&lt;void(EventDetails*)&gt;&gt;;
  </code></pre>