title: Message receive for c++ actor system
body: <p>I am trying to implement message handling for actors in c++. The following code in scala is something I am trying to implement in c++</p>
  
  <pre><code>def receive = {
      case Message1 =&gt;{/* logic code */}
      case Message2 =&gt;{/* logic code */}
   } 
  </code></pre>
  
  <p>Thus the idea is to create a set of handler functions for the various message type and create a dispatch method to route the message to its appropiate message handler. All messages will extends the base message type.</p>
  
  <p>What would be the best approach to solve this problem:</p>
  
  <ol>
  <li><p>Maintain a Map(Message_type, function_pointer), the dispatch method will check the map and call the appropiate method. This mapping however needs to be done mannually in the Actor class.</p></li>
  <li><p>I read this <a href="https://github.com/actor-framework/actor-framework/blob/master/examples/message_passing/dancing_kirby.cpp" rel="nofollow">library</a>, the lbrary is handling message exactly as I want to but I cant understand how they do pattern matching on the lambda fucntions created on line 56.</p></li>
  </ol>
  
  <p>I would appreciate any suggestion or reading links that could get me closer to the solution of this problem.</p>