jeudi 26 février 2015

Why can you combine constexpr with const? [duplicate]



This question already has an answer here:




The draft C++11 standard states that constexpr will declare an object as const:


7.1.5p9



A constexpr specifier used in an object declaration declares the object as const. Such an object shall have literal type and shall be initialized.



So it seems that constexpr const int i = 5; is redundant. However, combining const is explicitly disallowed:


7.1.6p2



const can be combined with any type specifier except itself.



Is there any reason why this rule wasn't extended to constexpr?




Aucun commentaire:

Enregistrer un commentaire