title: Best way to determine the type of an object at runtime
body: <p>So what I am trying to do is implementing the message pattern. And as far as I understand, the user will act upon what message type I put in, not the message type doing the action. Therefore, this is how I approach it:</p>
  
  <p>I want to get the datatype of the object so I can do a switch statement but I am not so sure where to start.</p>
  
  <p>I have looked through google and do some research but none is successful. This is what I have tried:</p>
  
  <ul>
  <li>Decltype : not even close to what I want</li>
  <li>typeof : I am not so clear about how to use</li>
  <li>dynamic-cast : not close to what I want</li>
  </ul>
  
  <p>Basically, what I want to have at the end is something like this:</p>
  
  <pre><code>switch (typeof(a)) {
      class_a : //do something
      class_b : //do something
  }
  </code></pre>
  
  <p>An if statement would work the same for me. Can anyone help me out? I would prefer using standard library.</p>