lundi 28 décembre 2015

C++ constexpr keyword placement

I have recently started using more C++11 features in my code and I have been wondering if the placement of the constexpr keyword makes difference whether it is before or after the constant's type.

Style 1:

constexpr int FOO = 1;
constexpr auto BAR = "bar";

Style 2:

int constexpr FOO = 1;
auto constexpr BAR = "bar";

Style 2 is the way I prefer to place the const keyword and placing constexpr the same way would bring some consistency to the code. However, is that considered bad practice or is there something else wrong with style 2 because I don't really see anyone writing it like that.

Aucun commentaire:

Enregistrer un commentaire