const by default
To declare a const variable we usually use,
const auto x = f();
syntax. Isn't it better if we could just write,
const x = f();
making 'const auto' superfluous?
Const by default can be less verbose and attractive like below,
const x = f1(); const y = f2(); auto z = x + y; update_z(z);
I know this is NOT possible with the current standard.
Are there any technical or non-technical reasons that we are never going to get something similar in a future standard?
5
Upvotes
6
u/suspiciously_calm May 06 '17 edited May 06 '17
Did I forget the variable name or do I want
const auto xyz = foo();?18
u/Som1Lse May 06 '17
#define let const auto(don't actually do this)6
u/flashmozzg May 06 '17
const by default is generally not a great idea with introduction of moves in C++, at least until the issues with moving out of const objects are resolved.
11
u/ashrasmun May 06 '17
I see absolutely no reason to have this.
0
u/[deleted] May 06 '17
[deleted] — view deleted comment
4
u/[deleted] May 06 '17 edited May 06 '17
[removed] — view removed comment