[PATCH] D123576: Support constructing empty function_ref from other callables that can be "empty"

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 09:12:17 PDT 2022


dblaikie added a comment.

In D123576#3475821 <https://reviews.llvm.org/D123576#3475821>, @mehdi_amini wrote:

> How do you see the list declared?
> I mean we can list std::function because we include the header, but would you / could you forward déclaré absl, folly, boost, etc. equivalent here? I feel I missed something?

Oh, I don't think it could/should be made compatible with those - only standard and llvm things.

> By the way an alternative it to do what absl does and remove the Boolean operator and force llvm::function_ref to always wrap something “non null” on construction

Sort of has the same issue, though - it'd require either ignoring the boolean testable semantics of the source functor (which would leave the same bugs in the program - we'd produce unqualified calls to the functor and crash at runtime) or we build in the assumption that any (or some subset of) boolean testable functor is expressing nullability and assert that the functor is true/non-null on conversion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123576



More information about the llvm-commits mailing list