dimanche 23 octobre 2016

Why is the conversion from char*** to char*const** invalid?

According to the latest draft of the C++ standard (N4606) , 4.5 [conv.qual] paragraph 3 reads

A prvalue expression of type T1 can be converted to type T2 if the following conditions are satisfied, where cvij denotes the cv-qualifiers in the cv-qualification signature of Tj:

  • ...
  • If the cv1i and cv2i are different, then const is in every cv2k for 0 < k < i.

The final bullet above suggests that the following conversion fails.

T1 : pointer to / pointer to /       pointer to / T
T2 : pointer to / pointer to / const pointer to / T

In order to succeed, T2 must be pointer to / const pointer to / const pointer to / T. Isn't T2 sufficient just for being more cv-qualified than T1? Why are more cv-qualifiers in lower dimensions necessary for the conversion to succeed?

Aucun commentaire:

Enregistrer un commentaire