Recasting const function
<p>I'm using a library (libtcod) that has an A* pathfinding algorithm. My class inherits the callback base class, and I implement the required callback function. Here is my generic example:</p>

<pre><code>class MyClass : public ITCODPathCallback
{
...
public: // The callback function
   float getWalkCost(int xFrom, int yFrom, int xTo, int yTo, void *userData ) const 
   {
      return this-&gt;doSomeMath();
   };
   float doSomeMath() { // non-const stuff }
};
</code></pre>

<p>I found a number of examples using const_cast and static_cast, but they seemed to be going the other way, making a non-const function be able to return a const function result. How can I do it in this example? </p>

<p>getWalkCost() is defined by my library that I cannot change, but I want to be able to do non-const things in it.</p>
