[PATCH] D73068: Reapply Avoid creating an immutable map in the Automaton class.
Marcello Maggioni via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 08:34:05 PST 2020
kariddi marked an inline comment as done.
kariddi added inline comments.
================
Comment at: llvm/include/llvm/Support/Automaton.h:238
/// templated on the type of these actions.
-template <typename ActionT> class Automaton {
+template <typename ActionT, template <typename ATy> class MapTy = TransitionMap>
+class Automaton {
----------------
jmolloy wrote:
> Does this compile? I'm confused by the syntax here.
Yeah, it compiles, we are passing the the map type as a template parameter (so if they user knows is not doing anything fancy with custom actions can use the one that just uses the ordered array in the background), but the map type is a templated type on the action type.
I chose to pass a template here instead of a class because if we passed a class the instantiation would have looked something like:
Automaton<uint64_t, OrderedArrayMap<uint64_t> A;
Duplicating the information about the action type in the instantiation (passed both to the automaton and the map), with this syntax we can do:
Automaton<uint64_t, OrderedArrayMap> A;
Another way I was thinking I could have done is pass the action type through the map and then just do:
Automaton<OrderedArrayMap<uint64_t>> A;
but the action type seems something that pertains the Automaton more than the map, so I liked more the first version.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73068/new/
https://reviews.llvm.org/D73068
More information about the llvm-commits
mailing list