[llvm-commits] [llvm] r86618 - /llvm/trunk/include/llvm/ADT/StringSwitch.h
Daniel Dunbar
daniel at zuster.org
Mon Nov 9 15:05:44 PST 2009
Author: ddunbar
Date: Mon Nov 9 17:05:44 2009
New Revision: 86618
URL: http://llvm.org/viewvc/llvm-project?rev=86618&view=rev
Log:
Add StringSwitch::Cases overloads, for matching multiple strings to a single
value.
Modified:
llvm/trunk/include/llvm/ADT/StringSwitch.h
Modified: llvm/trunk/include/llvm/ADT/StringSwitch.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringSwitch.h?rev=86618&r1=86617&r2=86618&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringSwitch.h (original)
+++ llvm/trunk/include/llvm/ADT/StringSwitch.h Mon Nov 9 17:05:44 2009
@@ -65,6 +65,25 @@
return *this;
}
+ template<unsigned N0, unsigned N1>
+ StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1],
+ const T& Value) {
+ return Case(S0, Value).Case(S1, Value);
+ }
+
+ template<unsigned N0, unsigned N1, unsigned N2>
+ StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1],
+ const char (&S2)[N2], const T& Value) {
+ return Case(S0, Value).Case(S1, Value).Case(S2, Value);
+ }
+
+ template<unsigned N0, unsigned N1, unsigned N2, unsigned N3>
+ StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1],
+ const char (&S2)[N2], const char (&S3)[N3],
+ const T& Value) {
+ return Case(S0, Value).Case(S1, Value).Case(S2, Value).Case(S3, Value);
+ }
+
T Default(const T& Value) {
if (ResultKnown)
return Result;
More information about the llvm-commits
mailing list