title: How is dynamic_cast typically implemented?
body: <p>Is the type check a mere integer comparison? Or would it make sense to have a <code>GetTypeId</code> virtual function to distinguishing which would make it an integer comparison?</p>
  
  <p>(Just don't want things to be a string comparison on the class names)</p>
  
  <p>EDIT: What I mean is, if I'm often expecting the wrong type, would it make sense to use something like:</p>
  
  <pre><code>struct Token
  {
      enum {
          AND,
          OR,
          IF
      };
      virtual std::size_t GetTokenId() = 0;
  };
  
  struct AndToken : public Token
  {
      std::size_t GetTokenId() { return AND; }
  };
  </code></pre>
  
  <p>And use the <code>GetTokenId</code> member instead of relying on <code>dynamic_cast</code>.</p>