title: Mechanism for extensible conditional statement
body: <p>I have these lines in my code:</p>
  
  <pre><code>//lines in mycode.c++
    QString str = "...some id...";
  
         if( str == "int")
             foo&lt; int&gt;()
    else if( str == "QString")
             foo&lt; QString&gt;()
         ...
  </code></pre>
  
  <p>I need to create a mechanism to include custom types in this conditional statement. So, any programmer can register his class and his implementation of <em>foo</em> templated function.</p>
  
  <p>I imagine it like this:</p>
  
  <pre><code>//A.h -- custom class
  class A { };
  
  template&lt; &gt;
    void foo&lt; A&gt;() { ... };
  
  DECL( A, "A"); //macro to declare class
  </code></pre>
  
  <p>I want conditional statement in <strong>mycode.c++</strong> that would automatically take in account declaration of class <em>A</em>, so it will have additional lines:</p>
  
  <pre><code>else if( str == "A")
      foo&lt; A&gt;()
  </code></pre>
  
  <p>I could have this effect like this:</p>
  
  <pre><code>//common.h
    void process_id( QString str) {
         if( str == "int")
             foo&lt; int&gt;()
    else if( str == "QString")
             foo&lt; QString&gt;()
         ...
    else if( str == "A") //this lines programmer put manually
             foo&lt; A&gt;();
    }
  
  //mycode.c++
    #include "common.h"
  
    QString str = "some_id";
  
    process_id( str);
  </code></pre>
  
  <p>but what if programmer forgets to edit <strong>common.h</strong> file?</p>
  
  <p>I thought, maybe to use C-macros system, or somehow Qt-precompilation. Is it possible?</p>