constexpr auto TEST1 = "test1"; is deduced as constexpr const char* TEST1 = "test1";
whereas adding an & to the above statement
constexpr auto& TEST1 = "test1"; deduces the expression as constexpr char const (&TEST1)[6] = "test1";
What I don't understand is that the type deduction fails for the below expression:
constexpr auto FILELIST[] = {"one.txt", "two.txt", "third.txt"};
with error:
error: 'FILELIST' declared as array of 'auto'
Of course if I replace the auto keyword with const char*, it works fine.
constexpr const char* const FILELIST[] = {"one.txt", "two.txt", "third.txt"};
Can you somebody please help in understanding what am i missing here?
Aucun commentaire:
Enregistrer un commentaire