This is an archive of the discontinued LLVM Phabricator instance.

Add StringSwitch::Cases functions that takes 6, 7 or 8 arguments.
ClosedPublic

Authored by ruiu on Sep 23 2016, 1:37 PM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu updated this revision to Diff 72344.Sep 23 2016, 1:37 PM
ruiu retitled this revision from to Add StringSwitch::Cases functions that takes 6, 7 or 8 arguments..
ruiu updated this object.
ruiu added a reviewer: zturner.
ruiu added a subscriber: llvm-commits.
ruiu updated this revision to Diff 72357.Sep 23 2016, 2:21 PM
  • Update as per Zach's comment.
zturner accepted this revision.Sep 23 2016, 3:10 PM
zturner edited edge metadata.
This revision is now accepted and ready to land.Sep 23 2016, 3:10 PM
This revision was automatically updated to reflect the committed changes.

I ended up in a situation where I needed 11 arguments (if you want a similar example, just grep for StringSwitch<bool> in MC).
I think the proposed solution was OK'ish up to 10 arguments, but adding more might be not ideal. So, now that we live in a post C++98 world, what do you think about switching this class to use variadic templating? I'm going to implement such a solution if nobody has objections. (cc: @dblaikie for thoughts)

davide added a comment.Sep 2 2017, 9:15 PM

I ended up in a situation where I needed 11 arguments (if you want a similar example, just grep for StringSwitch<bool> in MC).
I think the proposed solution was OK'ish up to 10 arguments, but adding more might be not ideal. So, now that we live in a post C++98 world, what do you think about switching this class to use variadic templating? I'm going to implement such a solution if nobody has objections. (cc: @dblaikie for thoughts)

See also https://reviews.llvm.org/D37420

Seems fine to me.

ruiu added a comment.Sep 5 2017, 5:19 PM

IIRC, it is tricky to use a template because all but the last parameter are of the same in Cases. If it takes Value as the first parameter, it would have been easier to use a template. But I'm not a C++ expert, so there may be a straightforward way of doing it.