[PATCH] D98477: [ADT] Add IntrusiveVariant, VariantTraits, and new STLForwardCompat

Scott Linder via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 26 14:08:20 PDT 2021


scott.linder updated this revision to Diff 348091.
scott.linder retitled this revision from "[ADT] Add IntrusiveVariant, in_place_index, and in_place_type" to "[ADT] Add IntrusiveVariant, VariantTraits, and new STLForwardCompat".
scott.linder edited the summary of this revision.
scott.linder added a comment.

Try to factor out the implementation of `visit` to be based on specializations
of a type `VariantTraits`. This should make it possible to share one
implementation with other variant-like types, for example PointerUnion.

Switch to an array-of-functions approach which doesn't have any restrictions on
the number of alternative types or the number of variants visited at once.

There are still some WIP things, including SFINAE tests on at least
llvm::visit, a lot of documentation, and the trait implementation for
PointerUnion. Other functions like `holds_alternative` and `get` could also be
handled in the same way.

I wanted to get feedback on the general approach before going any further.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98477

Files:
  llvm/include/llvm/ADT/IntrusiveVariant.h
  llvm/include/llvm/ADT/STLForwardCompat.h
  llvm/include/llvm/ADT/VariantTraits.h
  llvm/unittests/ADT/CMakeLists.txt
  llvm/unittests/ADT/IntrusiveVariantTest.cpp
  llvm/unittests/ADT/STLForwardCompatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98477.348091.patch
Type: text/x-patch
Size: 39857 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210526/91c802ab/attachment.bin>


More information about the llvm-commits mailing list