What is the static_cast runtime overhead if adding constness while keeping the same type?
I find it irritating that I can call non-const functions of an object if I have a pointer to this object. I cannot let the pointer be a const pointer because there are also non-const functions I need to call. Therefore, my only option seems to do static_casts to ensure that constness also works across pointers. Here is a minimal example: class MyClassImpl { MyClassImpl(void) : m_i(0) {} int increment(void) { ++m_i; return m_i; } private: int m_i; }; class MyClass { MyClass(void) : m_pImpl(new MyClassImpl()){} ~MyClass(void) { delete m_pImpl; } int doNothing(void) const { m_pImpl->increment();