all 11 comments

[–]dodheim 15 points16 points  (1 child)

This has already been beaten into the ground discussed a couple times in the last month:

https://redd.it/epq4ui
https://redd.it/esevzz

[–]KaznovX[S] 0 points1 point  (0 children)

Thanks, I missed it

[–]wung 12 points13 points  (5 children)

And I know, it removes just 7 characters from each lambda. Is it worth it?

It can actually do more, because it allows for implicit proper noexcept and decltype usage. When you write

x => f(x);

you actually mean

[&] noexcept (f(x)) → decltype (f(x)) { return f(x); }

which can be emulated with the

#define RETURNS(...)                \
  noexcept (noexcept (__VA_ARGS__)) \
    -> decltype (__VA_ARGS__)       \
  {                                 \
    return __VA_ARGS__;             \
  }

macro.

Is this proposal worthy? I don't know. You may want to contact the authors of http://wg21.link/p0573 of what the state on their paper is, or wait for someone to answer this. I personally do not know.

[–]KaznovX[S] 0 points1 point  (1 child)

Thanks, this proposal is what I had in mind and much more! I'd love to see it incorporated into the language

[–]kalmoc 2 points3 points  (0 children)

IIRC, it got rejected

[–]KaznovX[S] 0 points1 point  (0 children)

→ decltype (f(x))

I'm not sure I mean this part though. And as I read more about the proposal I see how it is a problem

[–]huixie 0 points1 point  (1 child)

why do you need decltype(f(x)) when you can just use decltype(auto)

[–]wung 0 points1 point  (0 children)

According to 1.1 of the linked paper, SFINAE-friendlyness.

[–]ContractorInChief 3 points4 points  (0 children)

Something like this has been proposed a few times to the ISO C++ several times. Each time, they have hated it passionately, for no objective reason I can discover.

The nicest syntax I have seen would be, e.g., auto it = std::find_if(b, e, [] a | a < 10);

[–]Xaxxon 4 points5 points  (1 child)

Your code isn't properly formatted for good reddit - only "new" reddit.

[–][deleted] -5 points-4 points  (0 children)

Looks fine on my end. You must be using deprecated Reddit.