title: Why can I call a non-const member function pointer from a const method?
body: <p>A co-worker asked about some code like this that originally had templates in it.</p>
  
  <p>I have removed the templates, but the core question remains: why does this compile OK?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class X
  {
  public:
       void foo() { std::cout &lt;&lt; "Here\n"; }
  };
  
  typedef void (X::*XFUNC)() ;
  
  class CX
  {
  public:
      explicit CX(X&amp; t, XFUNC xF) : object(t), F(xF) {}      
      void execute() const { (object.*F)(); }
  private:
      X&amp; object;
      XFUNC F;
  }; 
  
  int main(int argc, char* argv[])
  {   
      X x; 
      const CX cx(x,&amp;X::foo);
      cx.execute();
      return 0;
  }
  </code></pre>
  
  <p>Given that CX is a const object, and its member function <em>execute</em> is const, therefore inside CX::execute the <em>this</em> pointer is const.</p>
  
  <p>But I am able to call a non-const member function through a member function pointer.</p>
  
  <p>Are member function pointers a documented hole in the const-ness of the world?</p>
  
  <p>What (presumably obvious to others) issue have we missed?</p>