How to convert “pointer to pointer type” to const?

The language allows implicit conversion from double ** to const double *const *, but not to const double **. The conversion you attempt would implicitly violate the rules of const correctness, even though it is not immediately obvious.

The example in the [de-facto standard] C++ FAQ illustrates the issue

https://isocpp.org/wiki/faq/const-correctness#constptrptr-conversion

Basically, the rule is: once you add const at some level of indirection, you have to add const to all levels of indirection all the way to the right. For example, int ***** cannot be implicitly converted to int **const ***, but it can be implicitly converted to int **const *const *const *

Leave a Comment