[PATCH] D96794: [ADT] Add SFINAE guards to unique_function constructor.

Kadir Cetinkaya via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 17 00:20:11 PST 2021


kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!



================
Comment at: llvm/include/llvm/ADT/FunctionExtras.h:361
+      detail::EnableUnlessSameType<CallableT, unique_function> * = nullptr,
+      detail::EnableIfCallable<CallableT, R, P...> * = nullptr)
       : Base(std::forward<CallableT>(Callable),
----------------
sammccall wrote:
> kadircet wrote:
> > what about doing this in the constructor of the `UniqueFunctionBase` instead?
> I don't think this works even in principle, only the signatures are taken into account when resolving overloads, and the base-initialization is not part of the signature.
> https://godbolt.org/z/TWvcsE - see that the overload on the class with the sfinae constructor template works, but overloading on types derived from it is ambiguous.
> 
> Practically it also doesn't work because UniqueFunctionBase doesn't have access to R and P..., and you can't pass explicit template args to a constructor template.
> 
> (Or maybe I'm misunderstanding your suggestion)
no you understood correctly, i was missing the fact that base initialization required template instantiation. so nvm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96794



More information about the llvm-commits mailing list