[compiler-rt] faabefe - [ORC-RT] Add a std::identity substitute.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 26 15:58:34 PDT 2022


Author: Lang Hames
Date: 2022-08-26T15:58:10-07:00
New Revision: faabefe3c8a4755249e75cf8e2d3726460887946

URL: https://github.com/llvm/llvm-project/commit/faabefe3c8a4755249e75cf8e2d3726460887946
DIFF: https://github.com/llvm/llvm-project/commit/faabefe3c8a4755249e75cf8e2d3726460887946.diff

LOG: [ORC-RT] Add a std::identity substitute.

The __orc_rt::identity utility is intended to serve as a substitute for
c++20's std::identity until we can use the latter (when LLVM moves to c++20).

Added: 
    

Modified: 
    compiler-rt/lib/orc/stl_extras.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/orc/stl_extras.h b/compiler-rt/lib/orc/stl_extras.h
index ad7286e87ae34..e4f8bf0e96aa5 100644
--- a/compiler-rt/lib/orc/stl_extras.h
+++ b/compiler-rt/lib/orc/stl_extras.h
@@ -41,6 +41,16 @@ decltype(auto) apply_tuple(F &&f, Tuple &&t) {
                                   Indices{});
 }
 
+/// Substitute for std::identity.
+/// Switch to std::identity once we can use c++20.
+template <class Ty> struct identity {
+  using is_transparent = void;
+  using argument_type = Ty;
+
+  Ty &operator()(Ty &self) const { return self; }
+  const Ty &operator()(const Ty &self) const { return self; }
+};
+
 } // namespace __orc_rt
 
 #endif // ORC_RT_STL_EXTRAS


        


More information about the llvm-commits mailing list