[PATCH] D24882: Add StringSwitch::Cases functions that takes 6, 7 or 8 arguments.

Michael Spencer via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 6 13:00:23 PDT 2017


On Tue, Sep 5, 2017 at 7:09 PM, Davide Italiano <dccitaliano at gmail.com>
wrote:

> On Tue, Sep 5, 2017 at 6:32 PM, David Blaikie <dblaikie at gmail.com> wrote:
> >
> >
> > On Tue, Sep 5, 2017 at 5:26 PM Zachary Turner <zturner at google.com>
> wrote:
> >>
> >> Oh yea, I forgot about that issue.
> >>
> >> I know it is possible to have a parameter pack not be the last argument,
> >> so maybe it would work?  e.g.
> >>
> >> template<typename... Args>
> >> StringSwitch &Cases(Args &&... args, T value)
> >
> >
> > I think that's possible but doesn't deduce the varargs (only works if the
> > template parameters ar explicitly specified) - I could be wrong, though.
> >
> > The other way to do this is to SFINAE things (probably want to SFINAE all
> > the args to be Cases anyway).
> >
>
> Michael suggested the following, but it works only for C++14 (and beyond).
> https://godbolt.org/g/TLonbG
>
> I'll see if I can adapt to work with C++11.
>
> Thanks,
>
> --
> Davide
>

And here's a non n^2 version with less recursion.

https://godbolt.org/g/fT8RYu

- Michael Spencer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170906/0b79a3ec/attachment.html>


More information about the llvm-commits mailing list