title: Calling a const function from a non-const object
body: <p>I need to call a const function from a non-const object. See example</p>
  
  <pre><code>struct IProcess {
     virtual bool doSomeWork() const = 0L;
  };
  class Foo : public IProcess {    
    virtual bool doSomeWork() const {
      ...
    }
  };
  
  class Bar
  {
  public:
     const IProcess&amp; getProcess() const {return ...;}
     IProcess&amp; getProcess() {return ...;}
  
     void doOtherWork {
      getProcess().doSomeWork();        
    }
  };
  </code></pre>
  
  <p>Calling </p>
  
  <pre><code>getProcess().doSomeWork();
  </code></pre>
  
  <p>will always results in a call to</p>
  
  <pre><code>IProcess&amp; getProcess()
  </code></pre>
  
  <p>Is there another way to call</p>
  
  <pre><code>const IProcess&amp; getProcess() const 
  </code></pre>
  
  <p>from a non constant member function?
  I have so far used</p>
  
  <pre><code>const_cast&lt;const Bar*&gt;(this)-&gt;getProcess().doSomeWork();
  </code></pre>
  
  <p>which does the trick but seems overly complicated.</p>
  
  <hr>
  
  <p>Edit: I should mention that code is being refactored and eventually only one function will remain.</p>
  
  <pre><code>const IProcess&amp; getProcess() const 
  </code></pre>
  
  <p>However, currently there is a side effect and the const call may return a different instance of IProcess some of the time.</p>
  
  <p>Please keep on topic.</p>