Warning: ISO C++ forbids converting a string constant to ‘char*’ for a static `constexpr char*` data member [duplicate]

constexpr does imply const, but in this case it applies const to the “wrong thing”.

constexpr char*

is basically the same as

char * const

which is a constant pointer to a non-const char. This won’t work because string literals have the type const char[N] so it would cast away the constness of the array elements.

constexpr const char*

on the other hand, is basically the same as

char const * const

which is a constant pointer to a constant char, which is what you want as it preserves the constness of the elements.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)