MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/1t2xmw4/the_most_confusing_c_behavior/oju2c2l/?context=3
r/cpp • u/levodelellis • May 03 '26
51 comments sorted by
View all comments
Show parent comment
3
You are an AA guy my friend? So why not east-const instead of const-west :P.For me, it's always auto const val = 10;
auto const val = 10;
Jokes aside, regarding the branched initialization one could also use lambdas or statement expressions.
auto const val = [expr] { if(expr) return init_true(); return init_false(); }()Then OP does not need to slide anything through.
auto const val = [expr] { if(expr) return init_true(); return init_false(); }()
4 u/EdwinYZW May 04 '26 Yes. Immediately call a lambda is also a nice trick to make a constant. :Dconst-west is more readable for me in normal situations, unless I'm dealing int const. So I would rather use int constint const.
4
Yes. Immediately call a lambda is also a nice trick to make a constant. :D
const-west is more readable for me in normal situations, unless I'm dealing int const. So I would rather use int constint const.
View all comments
Show parent comment
3
u/Wild_Meeting1428 May 04 '26
You are an AA guy my friend? So why not east-const instead of const-west :P.
For me, it's always
auto const val = 10;Jokes aside, regarding the branched initialization one could also use lambdas or statement expressions.
auto const val = [expr] { if(expr) return init_true(); return init_false(); }()Then OP does not need to slide anything through.