Recently I found a piece of C++ code that effectively does the following:
char* pointer = ...;
const char* constPointer = const_cast<const char*>( pointer );
Obviously the author thought that const_cast
means "add const", but in fact const
can be just as well added implicitly:
const char* constPointer = pointer;
Is there any case when I would really have to const_cast
to a pointer-to-const (const_cast<const Type*>
as in above example)?