[PATCH] D99560: Utility to construct visitors from lambdas.

Eugene Zhulenev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 2 21:39:31 PDT 2021


ezhulenev added a comment.

`std::forward` with inheritance does not remove a need to invoke a copy constructors, I managed to implement `overloaded` using a struct member and super ugly SFINAE that does properly captures lambdas by reference when lambda is a lvalue, however it still does need to copy when lambda is rvalue: https://godbolt.org/z/dqshPW6h1 (top most example, I just count the number of `HeavyStuff::HeavyStuff(HeavyStuff const&)` copy constructor calls in the generated code). But it does look much worse than inheritance.

Though with `-O3` version with forward and version with struct member generate less code than copying by value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99560



More information about the llvm-commits mailing list