[PATCH] D99561: Support visitor pattern by PointerUnion.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 31 14:46:17 PDT 2021


dblaikie added a comment.

In D99561#2660503 <https://reviews.llvm.org/D99561#2660503>, @ezhulenev wrote:

> True `llvm::visit` API similar to `std::visit` requires visited type <https://en.cppreference.com/w/cpp/utility/variant/visit> to be a `std::variant` (`llvm::variant`?) and implementng it is a lot of code (e.g. implementation in absl <https://github.com/abseil/abseil-cpp/blob/master/absl/types/variant.h>). Given that it's unlikely that `PointerUnion` at any point will become `std::variant`, I'd say that it will always be a separate API. And for this usability improvement the change is not that large.

it's not so much that PointerUnion might be replaced by std::variant one day - I agree that that's not expected.

It's that having two similar types with slightly different ways of spelling similar operations would be a hinderance to programmer productivity - having to think about which one to use in the given context. Not that this'd come up all that often, but consistency is nice to have.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99561



More information about the llvm-commits mailing list