Why does static_cast not use the conversion operator to pointer to const?

There is only one conversion allowed, so you can convert to Base, but it cannot be converted afterwards to Derived.

So you have to use two consecutive casts. It's safer anyway because you state that you know that you are converting from a Base to a Derived. You should never have an implicit conversion from a base class to a derived class.


You need to process in two steps as you're trying to convert Pointer<Base>* ---(1)---> Base const* ---(2)---> Derived const*, with:

  1. Pointer<Base>::operator Base const*
  2. downcast.

e.g.

Base const* pb = static_cast<Base const *>(p);
Derived const *pd = static_cast<Derived const*>(pb);

Live demo.