title: C++ multimethods and compile time detection
body: <p>I have the following code :</p>
  
  <pre><code>class A{};
  class B: public A{};
  class C: public A{};
  
  class MyVisitor
  {
     public:
         void visit(B*);
         void visit(C*);
  };
  </code></pre>
  
  <p>And then collection of A* objects, I want to achieve the following :</p>
  
  <p>1) </p>
  
  <pre><code>MyVisitor visitor;
  for(vector&lt;A*&gt;::iterator it = vec.begin(); it!= vec.end();it++)
       visitor-&gt;visit(a);
  </code></pre>
  
  <p>2) Somehow determine at compile time, if A* points to derived object D,and give compiler error, if <code>MyVisitor::visit(D*)</code> function is not present </p>
  
  <p>I know that 1) is achievable with some multimethods implementation, I guess I can find some implementations of multimethods for c++ . But is 2) somehow possible ?</p>