libcamera: bound_method: Use std::apply
diff mbox series

Message ID 20260508221033.2417134-1-laurent.pinchart@ideasonboard.com
State New
Headers show
Series
  • libcamera: bound_method: Use std::apply
Related show

Commit Message

Laurent Pinchart May 8, 2026, 10:10 p.m. UTC
Now that libcamera uses C++20, we can use std::apply to replace the
custom implementation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 include/libcamera/base/bound_method.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)


base-commit: 2ca75f012fa12621ed70e333e635d173e92593e5

Patch
diff mbox series

diff --git a/include/libcamera/base/bound_method.h b/include/libcamera/base/bound_method.h
index 91fe8b8cb969..ad5374f70b18 100644
--- a/include/libcamera/base/bound_method.h
+++ b/include/libcamera/base/bound_method.h
@@ -91,15 +91,14 @@  public:
 	using PackType = BoundMethodPack<R, Args...>;
 
 private:
-	template<std::size_t... I>
-	void invokePack(BoundMethodPackBase *pack, std::index_sequence<I...>)
+	void invokePack(PackType *args)
 	{
-		[[maybe_unused]] auto *args = static_cast<PackType *>(pack);
-
 		if constexpr (!std::is_void_v<R>)
-			args->ret_ = invoke(std::get<I>(args->args_)...);
+			args->ret_ = std::apply(&BoundMethodArgs::invoke,
+						std::tuple_cat(std::forward_as_tuple(this), args->args_));
 		else
-			invoke(std::get<I>(args->args_)...);
+			std::apply(&BoundMethodArgs::invoke,
+				   std::tuple_cat(std::forward_as_tuple(this), args->args_));
 	}
 
 public:
@@ -108,7 +107,7 @@  public:
 
 	void invokePack(BoundMethodPackBase *pack) override
 	{
-		invokePack(pack, std::make_index_sequence<sizeof...(Args)>{});
+		invokePack(static_cast<PackType *>(pack));
 	}
 
 	virtual R activate(Args... args, bool deleteMethod = false) = 0;