[llvm] [STLExtras] Introduce bind_{front, back}, [not_]equal_to (PR #175056)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 12 07:44:27 PST 2026


================
@@ -175,6 +193,23 @@ struct from_range_t {
   explicit from_range_t() = default;
 };
 inline constexpr from_range_t from_range{};
+
+// The behvaior is the same as std::bind_back, with the following difference:
+// The value catagory and const of the returned lambda are not considered when
+// calling it. An approach to handle them is using deducing this and
+// std::forward_like (C++23).
+template <typename FnT, typename... BindArgsT>
+constexpr auto bind_back(FnT &&Fn, // NOLINT(readability-identifier-naming)
+                         BindArgsT &&...BindArgs) {
+  if constexpr (std::is_pointer_v<FnT> or std::is_member_pointer_v<FnT>)
+    static_assert(Fn != nullptr);
+
+  return [Fn = std::forward<FnT>(Fn),
+          BindArgs = std::forward_as_tuple(BindArgs...)](auto &&...CallArgs) {
+    return std::apply(
+        Fn, std::tuple_cat(std::forward_as_tuple(CallArgs...), BindArgs));
----------------
kuhar wrote:

Same here

https://github.com/llvm/llvm-project/pull/175056


More information about the llvm-commits mailing list