I put it in the front, but it's just a matter of personal preference. "Const T" and "T const" are always allowed, and are equivalent. For example:
const int a = 1; OK
int const B = 2;//also OK
I suspect that the first version may be confusing to a handful of programmers (who are more likely to stick to the rules of grammar).
Why? When I invent "const" (the original name is called "ReadOnly" and there is a corresponding "WriteOnly"), I allow it to appear before or after the type, because it does not bring any uncertainty. Pre-standard C and C + + Specify a few (if any) specific order specifications.
I don't remember having any in-depth thoughts or discussions on the sequencing issue at that time. At that time, some of the early adopters--especially me--just liked it:
Looks better than this:
Perhaps I have also been affected by this: in my earliest examples of using "ReadOnly"
is more readable than this:
The first "const" (c or C + +) code I've created seems to have replaced the "readonly" around the world.
I remember that the choice of grammar was discussed in several people, such as Dennis ritchie--, but I don't remember what language I was leaning towards.
Note In the fixed pointer (const pointer), "const" always appears after "*". For example:
int *const p1 = q; Fixed pointer
int const* p2 = q pointing to int variable://pointer to int constant
int* p3 = q;//pointer to int constant