Hi, I think I don’t fully understand,
You want to assign a name to a lambda when passing it as an argument to a function with => operator?

Cheers, Filip

Wiadomość napisana przez Marcin Jaczewski via Std-Proposals <std-proposals@lists.isocpp.org> w dniu 1 lut 2025, o godz. 16:35:

One problem with the previous proposal was what value category
should return type be, some prefer it as value other prefer reference.
Question why not allow both? We could have 3 types of arrows:

```
=> //return value (if not specified explicitly)
&=> //return reference
&&=> //return forward reference
```

only `decltype(auto)` is not easily available but this
probably is only for very special cases.

Most safe version need least typing and is simplest.
Another thing syntax is intuitive, when someone sees `&`
one of their first thoughts should be "reference?".

This syntax could be consider of contraction of full syntax:

```
[x]() -> auto&   => x;
[x]() -> auto   &=> x;
[x]() &=> x;
```

Only drawback of syntax like this could break some current code like:

```
foo<&T::operator=>() // could see `=>` instead of current `=` and `>`
foo<&T::operator&=>() //similar `&=>` as one token.
```

But we could simply handle this similar to `>>` in template context
and require brackets:

```
foo<&T::operator=> //split `=` and `>`
foo<([] => 42)>
```



If someone specify `->` and `=>` like:

```
template<typename T>
void foo(T&& t)
{
   bar([&] -> T&   &&=> t);
   bar([&] -> T&&   &=> t);
   bar([&]              &=> t);
}
```

Then similarly like forward reference parameters, all return types
will have the same value category of `&`.
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals