hliao added a comment.

In D78655#2117216 <https://reviews.llvm.org/D78655#2117216>, @pfultz2 wrote:

> > Now, back to the specifics of your example. I'm still not 100% sure I 
> > understand what the problem is. Can you boil down the use case to an 
> > example on godbolt?
>
> I dont have a specific example, but there could be code like this generic 
> `clip` operator:
>
>   template<class F, class T>
>   void clip(F f,
>             const T& min_val,
>             const T& max_val)
>   {
>  
>       f([=](auto x) {
>           return ::min<decltype(x)>(::max<decltype(x)>(min_val, x), max_val);
>       });
>   }
>


What's the expected HD property of this template function `clip`? Why we cannot 
ask developers to add the same HD property for that inner lambda?

> Its not clear to the writer of the generic function that it needs to declare 
> the lambda with an explicit HD.
> 
>> If Sam decides to incorporate support for capturing lambdas in this patch, 
>> we could still do it by restricting the capturing lambda promotion to the 
>> ones within a function scope only. I.e. lambdas created in global scope 
>> would still be host.
> 
> I think that would be acceptable. I dont think global scope capturing lambdas 
> are very common due to possible ODR issues.




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78655/new/

https://reviews.llvm.org/D78655



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to