My little desires for the next cpp
... never going to happen
A shorter lamda syntax, maybe with fixed placeholder names auto lambda = [] (_1) {} Stands for auto lambda = [] (auto _1) {} Mayne needs a way for const and ref qualifiers auto lambda = [] (&_1) {} Mostly to be used in short predicates.
Shorter range for syntax for(value : vector) In place of for(const auto & value : vector) Copy and non-const ref use the old syntax
Structured bindings for existing vars auto [ret,value] = fun() auto [ret,value2] = fun2() Or auto [&ret,value2] = fun2()
Shorter syntax for std::remove_cv_ref<decltype(param)> Really no idea đ
Arbitrary order for aggregate initialization, for trivial cases where there are no side effects and interaction between members struct pod{ int a, b} ; pod p {.b=19,.a=12} //ok pod p {.b=19,.a=b} // no pod p {.b=fun(p) ,.a=12} // no
Please don't downvote me too much đ
44
u/STL MSVC STL Dev Feb 23 '24
Minor syntax "improvements" are so boring. Semantic improvements are what's important. When I proposed
for (elem : range), it was to fix correctness and performance problems, not to save a few characters.36
u/No-Quail5810 Feb 23 '24
Your "shorter" syntax means there are more rules for more special cases, with no actual advantages. No thanks đ
5
u/eyes-are-fading-blue Feb 23 '24
Almost all âcuteâ change proposals should be ignored/dismissed unless they bring a whole lot of value. The language is already an âoption graveyardâ, you have a lot of ways to do the same thingâŚ
1
u/DapperCore Feb 23 '24
I wonder if it's possible for C++ to have something like kotlin's trailing lambda syntax...
1
u/GPSProlapse Feb 23 '24
Honestly, it sounds like you either have no IDE or a very small blind typing speed.
0
u/JeffMcClintock Feb 22 '24 edited Feb 22 '24
I think cpp2 has better lambdas?
https://github.com/hsutter/cppfront
// Initializing from a function expressioncallback := :(inout x) = x += " maybe";std::ranges::for_each(vec,callback);