[PATCH] D88977: Reapply [ADT] function_ref's constructor is unavailable if the argument is not callable.

Sam McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 7 09:31:00 PDT 2020


sammccall added a comment.

In D88977#2317022 <https://reviews.llvm.org/D88977#2317022>, @kadircet wrote:

> If you have some pointers to gcc bug being discussed in some place, it might be nice to include.

I didn't find them, and they're fixed as since gcc 7 so it doesn't really make sense to file a bug :-(



================
Comment at: llvm/include/llvm/ADT/STLExtras.h:201
+      // Functor must be callable and return a suitable type.
+      std::enable_if_t<std::is_void<Ret>::value ||
+                       std::is_convertible<
----------------
kadircet wrote:
> nit: I would propbably merge the two into a single parameter, but up to you.
> 
> ```
> std::enable_if_t<
> // This is not the copy-constructor.
> !std::is_same<std::remove_cv_t<std::remove_reference_t<Callable>>,
>                         function_ref>::value &&
> // Functor must be callable and return a suitable type.
> (std::is_void<Ret>::value || std::is_convertible<
>                            std::result_of_t<Callable(Params...)>, Ret>::value)> * = nullptr
> ```
Clang (and maybe GCC?) has special support for diagnosing substitution failure with enable_if: it says "requirement failed" and dumps the expression. So the fewer/larger the expressions are, the less useful it is.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88977/new/

https://reviews.llvm.org/D88977



More information about the llvm-commits mailing list