[PATCH] D132628: [ADT] Make `llvm::identity` a transparent function object

Joe Loser via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 18:37:14 PDT 2022


jloser created this revision.
jloser added reviewers: scott.linder, dblaikie, MaskRay.
Herald added a subscriber: StephenFan.
Herald added a project: All.
jloser requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

`llvm::identity` is similar to `std::identity` from C++20, but one surprising
thing is that `llvm::identity` is not a transparent function object. Add the
`is_transparent` type alias to denote it can be used as a transparent function
object.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132628

Files:
  llvm/include/llvm/ADT/identity.h


Index: llvm/include/llvm/ADT/identity.h
===================================================================
--- llvm/include/llvm/ADT/identity.h
+++ llvm/include/llvm/ADT/identity.h
@@ -18,7 +18,9 @@
 
 namespace llvm {
 
+// Similar to `std::identity` from C++20.
 template <class Ty> struct identity {
+  using is_transparent = void;
   using argument_type = Ty;
 
   Ty &operator()(Ty &self) const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132628.455455.patch
Type: text/x-patch
Size: 403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220825/80ac92f8/attachment.bin>


More information about the llvm-commits mailing list