mardi 3 mars 2015

constexpr const vs constexpr variables?

It seems obvious that constexpr implies const and thus it is common to see:



constexpr int foo = 42; // no const here


However if you write:



constexpr char *const str = "foo";


Then GCC will spawn "warning: deprecated conversion from string constant to ‘char*’" if -Wwrite-string flag is passed.


Writing:



constexpr const char *const str = "foo";


solves the issue.


So are constexpr const and constexpr really the same?


Aucun commentaire:

Enregistrer un commentaire