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

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 4 08:34:46 PDT 2021


dblaikie added a comment.

In D99560#2667327 <https://reviews.llvm.org/D99560#2667327>, @ezhulenev wrote:

> It’s impossible to statically dispatch to the correct lambda with such API (or at least a very difficult exercise). std::visit takes a single visitor and multiple variants, not the other way around. Stitching lambdas together is just one way of constructing a visitor type, it can be a plain old class with overloaded operator() set.

ah, fair point about the std::visit API design taking a type with op() overloads and using that to resolve which call, etc.

could makeVisitor at least be improved to support move-only functors (& avoid unnecessary copies of copyable functors too, when they could instead be efficiently moved), perhaps? I hope that wouldn't add too much complexity (probably a few std::forwards here and there)


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