ASTMatchers: Replace enable_if with static_assert.
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 16 Feb 2015 11:08:00 +0000 (11:08 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 16 Feb 2015 11:08:00 +0000 (11:08 +0000)
This is nicer in general and gives a better error message, but it also might
bring MSVC 2013 back to life.

llvm-svn: 229374

clang/include/clang/ASTMatchers/ASTMatchersInternal.h

index 2b98e9a..3f4d649 100644 (file)
@@ -1178,14 +1178,10 @@ template <unsigned MinCount, unsigned MaxCount>
 struct VariadicOperatorMatcherFunc {
   DynTypedMatcher::VariadicOperator Op;
 
-  template <unsigned Count, typename T>
-  struct EnableIfValidArity
-      : public std::enable_if<MinCount <= Count && Count <= MaxCount, T> {};
-
   template <typename... Ms>
-  typename EnableIfValidArity<sizeof...(Ms),
-                              VariadicOperatorMatcher<Ms...>>::type
-  operator()(Ms &&... Ps) const {
+  VariadicOperatorMatcher<Ms...> operator()(Ms &&... Ps) const {
+    static_assert(MinCount <= sizeof...(Ms) && sizeof...(Ms) <= MaxCount,
+                  "invalid number of parameters for variadic matcher");
     return VariadicOperatorMatcher<Ms...>(Op, std::forward<Ms>(Ps)...);
   }
 };