r229374 - ASTMatchers: Replace enable_if with static_assert.

Richard Smith richard at metafoo.co.uk
Wed Feb 18 18:07:01 PST 2015


On Mon, Feb 16, 2015 at 3:08 AM, Benjamin Kramer <benny.kra at googlemail.com>
wrote:

> Author: d0k
> Date: Mon Feb 16 05:08:00 2015
> New Revision: 229374
>
> URL: http://llvm.org/viewvc/llvm-project?rev=229374&view=rev
> Log:
> ASTMatchers: Replace enable_if with static_assert.
>
> This is nicer in general and gives a better error message, but it also
> might
> bring MSVC 2013 back to life.
>
> Modified:
>     cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
>
> Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=229374&r1=229373&r2=229374&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
> +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Mon Feb 16
> 05:08:00 2015
> @@ -1178,14 +1178,10 @@ template <unsigned MinCount, unsigned Ma
>  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 {
>

Why the space after the '...'? That seems to be in conflict with the usual
LLVM style.


> +    static_assert(MinCount <= sizeof...(Ms) && sizeof...(Ms) <= MaxCount,
> +                  "invalid number of parameters for variadic matcher");
>      return VariadicOperatorMatcher<Ms...>(Op, std::forward<Ms>(Ps)...);
>    }
>  };
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150218/89207604/attachment.html>


More information about the cfe-commits mailing list