[PATCH] D103223: [ADT][WIP] Proof of concept impl of generic visit for PointerUnion

Scott Linder via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 4 09:45:09 PDT 2021


scott.linder added inline comments.


================
Comment at: llvm/include/llvm/ADT/PointerUnion.h:282
+  static constexpr size_t getIndex(const PointerUnion<PTs...> &Variant) {
+    return Variant.Val.getInt();
+  }
----------------
dblaikie wrote:
> Is this the only reason the variant traits needs to be befriended by the PointerUnion? If so, perhaps this API could be exposed in PointerUnion's public API rather than using friendship?
>From a pure perspective I think it is an implementation detail, which is the same reason I didn't expose the `index` in `IntrusiveVariant` either. It seems reasonable to expose, as `std::variant` does expose an `::index` method, but I can't think of many uses of it that don't have a better, type-safe alternative.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103223



More information about the llvm-commits mailing list