[3/4] libcamera: vector: Support multiple scalar arguments to apply()
diff mbox series

Message ID 20260621002305.3763752-4-laurent.pinchart@ideasonboard.com
State New
Headers show
Series
  • libcamera: vector: Add clamp() function
Related show

Commit Message

Laurent Pinchart June 21, 2026, 12:23 a.m. UTC
In preparation for the addition of a clamp() function to the vector
class, extend the apply() function to support multiple scalar arguments.

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

Patch
diff mbox series

diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h
index 256de1d1c53a..7c90d6542352 100644
--- a/include/libcamera/internal/vector.h
+++ b/include/libcamera/internal/vector.h
@@ -274,13 +274,13 @@  private:
 		return result;
 	}
 
-	template<typename BinaryOp, typename U>
-	static constexpr Vector apply(const Vector &lhs, BinaryOp op, U rhs)
+	template<typename Op, typename... U>
+	static constexpr Vector apply(const Vector &vector, Op op, U... scalar)
 	{
 		Vector result;
-		std::transform(lhs.data_.begin(), lhs.data_.end(),
+		std::transform(vector.data_.begin(), vector.data_.end(),
 			       result.data_.begin(),
-			       [&op, rhs](T v) { return op(v, rhs); });
+			       [&op, scalar...](T v) { return op(v, scalar...); });
 
 		return result;
 	}
@@ -295,11 +295,11 @@  private:
 		return *this;
 	}
 
-	template<typename BinaryOp, typename U>
-	Vector &apply(BinaryOp op, U scalar)
+	template<typename Op, typename... U>
+	Vector &apply(Op op, U... scalar)
 	{
 		std::for_each(data_.begin(), data_.end(),
-			      [&op, scalar](T &v) { v = op(v, scalar); });
+			      [&op, scalar...](T &v) { v = op(v, scalar...); });
 
 		return *this;
 	}