title: Cast derived virtual override to base pure virtual member
body: <p>I understand why you cannot simply cast a derived class member function pointer to base class member function pointer as explained <a href="https://stackoverflow.com/questions/15971013/using-base-class-function-pointer-to-access-derived-class-member-function">here</a>.</p>
  
  <p>But, given this snippet:</p>
  
  <pre><code>struct base
  {
      virtual void foo() = 0;
  };
  
  struct derived : base
  {
      void foo() override {};
  };
  
  struct invoker
  {
      typedef void(base::*target)();
  
      invoker(base* b, target t)
      {
          (b-&gt;*t)();
      }
  };
  
  template&lt;typename B, typename D&gt;
  void (B::*cast(void (D::*method)()))()
  {
      return static_cast&lt;void(B::*)()&gt;(method);
  }
  
  derived d;
  invoker bad(&amp;d, &amp;derived::foo); //C2664
  invoker good(&amp;d, cast&lt;base&gt;(&amp;derived::foo));
  </code></pre>
  
  <p>I wanted to ask is it possible to decorate the base function signature so that compiler understands it is a pure virtual method and and it will be implemented somewhere across the hierarchy (otherwise I could not construct an object of type <code>B</code>)? I understand why I can't do this with normal functions, but IMHO in case of a pure virtual function the compiler has a guarantee it will be implemented (in case it was not done I would get an error about the class <code>B</code> not about the cast).</p>