| Message ID | 20260622101536.3886913-1-laurent.pinchart@ideasonboard.com |
|---|---|
| State | Accepted |
| Headers | show |
| Series |
|
| Related | show |
2026. 06. 22. 12:15 keltezéssel, Laurent Pinchart írta: > The implementation of operator{+,-,/,*}= uses custom lambdas the instead of > std::plus, std::minus, std::multiplies and std::divides standard > objects. Replace the manual implementation to simplify the code. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > This patch applies on top of "[PATCH 0/4] libcamera: vector: Add clamp() > function". > --- Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > include/libcamera/internal/vector.h | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h > index 0270651a0ef7..0af629e69d56 100644 > --- a/include/libcamera/internal/vector.h > +++ b/include/libcamera/internal/vector.h > @@ -120,42 +120,42 @@ public: > > Vector &operator+=(const Vector &other) > { > - return apply([](T a, T b) { return a + b; }, other); > + return apply(std::plus<>{}, other); > } > > Vector &operator+=(T scalar) > { > - return apply([](T a, T b) { return a + b; }, scalar); > + return apply(std::plus<>{}, scalar); > } > > Vector &operator-=(const Vector &other) > { > - return apply([](T a, T b) { return a - b; }, other); > + return apply(std::minus<>{}, other); > } > > Vector &operator-=(T scalar) > { > - return apply([](T a, T b) { return a - b; }, scalar); > + return apply(std::minus<>{}, scalar); > } > > Vector &operator*=(const Vector &other) > { > - return apply([](T a, T b) { return a * b; }, other); > + return apply(std::multiplies<>{}, other); > } > > Vector &operator*=(T scalar) > { > - return apply([](T a, T b) { return a * b; }, scalar); > + return apply(std::multiplies<>{}, scalar); > } > > Vector &operator/=(const Vector &other) > { > - return apply([](T a, T b) { return a / b; }, other); > + return apply(std::divides<>{}, other); > } > > Vector &operator/=(T scalar) > { > - return apply([](T a, T b) { return a / b; }, scalar); > + return apply(std::divides<>{}, scalar); > } > > Vector &operator>>=(unsigned int shift) > > base-commit: bd266aa3405d3aea20b407b27e52482b02146030 > prerequisite-patch-id: cd23c4b11eb03f4ed3a6ce924dc40b2122c3d996 > prerequisite-patch-id: 9134d77756d5822a87717f016e7f0b0f0b11caf2 > prerequisite-patch-id: 76085046643e01f0e288e8d1eab0eae4c3cd653e > prerequisite-patch-id: f2029084f2d806ad9587d3a274beb6e42b63fb23 > -- > Regards, > > Laurent Pinchart >
On Mon, Jun 22, 2026 at 10:29:22AM +0000, Barnabás Pőcze wrote: > 2026. 06. 22. 12:15 keltezéssel, Laurent Pinchart írta: > > The implementation of operator{+,-,/,*}= uses custom lambdas the > > instead of I think I lost a whole line of commit message. I don't recall what I had written, so I'll just add "instead of" :-) > > std::plus, std::minus, std::multiplies and std::divides standard > > objects. Replace the manual implementation to simplify the code. > > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > --- > > This patch applies on top of "[PATCH 0/4] libcamera: vector: Add clamp() > > function". > > --- > > Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > > > > include/libcamera/internal/vector.h | 16 ++++++++-------- > > 1 file changed, 8 insertions(+), 8 deletions(-) > > > > diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h > > index 0270651a0ef7..0af629e69d56 100644 > > --- a/include/libcamera/internal/vector.h > > +++ b/include/libcamera/internal/vector.h > > @@ -120,42 +120,42 @@ public: > > > > Vector &operator+=(const Vector &other) > > { > > - return apply([](T a, T b) { return a + b; }, other); > > + return apply(std::plus<>{}, other); > > } > > > > Vector &operator+=(T scalar) > > { > > - return apply([](T a, T b) { return a + b; }, scalar); > > + return apply(std::plus<>{}, scalar); > > } > > > > Vector &operator-=(const Vector &other) > > { > > - return apply([](T a, T b) { return a - b; }, other); > > + return apply(std::minus<>{}, other); > > } > > > > Vector &operator-=(T scalar) > > { > > - return apply([](T a, T b) { return a - b; }, scalar); > > + return apply(std::minus<>{}, scalar); > > } > > > > Vector &operator*=(const Vector &other) > > { > > - return apply([](T a, T b) { return a * b; }, other); > > + return apply(std::multiplies<>{}, other); > > } > > > > Vector &operator*=(T scalar) > > { > > - return apply([](T a, T b) { return a * b; }, scalar); > > + return apply(std::multiplies<>{}, scalar); > > } > > > > Vector &operator/=(const Vector &other) > > { > > - return apply([](T a, T b) { return a / b; }, other); > > + return apply(std::divides<>{}, other); > > } > > > > Vector &operator/=(T scalar) > > { > > - return apply([](T a, T b) { return a / b; }, scalar); > > + return apply(std::divides<>{}, scalar); > > } > > > > Vector &operator>>=(unsigned int shift) > > > > base-commit: bd266aa3405d3aea20b407b27e52482b02146030 > > prerequisite-patch-id: cd23c4b11eb03f4ed3a6ce924dc40b2122c3d996 > > prerequisite-patch-id: 9134d77756d5822a87717f016e7f0b0f0b11caf2 > > prerequisite-patch-id: 76085046643e01f0e288e8d1eab0eae4c3cd653e > > prerequisite-patch-id: f2029084f2d806ad9587d3a274beb6e42b63fb23
Quoting Laurent Pinchart (2026-06-22 11:15:36) > The implementation of operator{+,-,/,*}= uses custom lambdas the > std::plus, std::minus, std::multiplies and std::divides standard > objects. Replace the manual implementation to simplify the code. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > This patch applies on top of "[PATCH 0/4] libcamera: vector: Add clamp() > function". > --- > include/libcamera/internal/vector.h | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h > index 0270651a0ef7..0af629e69d56 100644 > --- a/include/libcamera/internal/vector.h > +++ b/include/libcamera/internal/vector.h > @@ -120,42 +120,42 @@ public: > > Vector &operator+=(const Vector &other) > { > - return apply([](T a, T b) { return a + b; }, other); > + return apply(std::plus<>{}, other); > } > > Vector &operator+=(T scalar) > { > - return apply([](T a, T b) { return a + b; }, scalar); > + return apply(std::plus<>{}, scalar); > } > > Vector &operator-=(const Vector &other) > { > - return apply([](T a, T b) { return a - b; }, other); > + return apply(std::minus<>{}, other); > } > > Vector &operator-=(T scalar) > { > - return apply([](T a, T b) { return a - b; }, scalar); > + return apply(std::minus<>{}, scalar); > } > > Vector &operator*=(const Vector &other) > { > - return apply([](T a, T b) { return a * b; }, other); > + return apply(std::multiplies<>{}, other); > } > > Vector &operator*=(T scalar) > { > - return apply([](T a, T b) { return a * b; }, scalar); > + return apply(std::multiplies<>{}, scalar); > } > > Vector &operator/=(const Vector &other) > { > - return apply([](T a, T b) { return a / b; }, other); > + return apply(std::divides<>{}, other); > } > > Vector &operator/=(T scalar) > { > - return apply([](T a, T b) { return a / b; }, scalar); > + return apply(std::divides<>{}, scalar); > } > > Vector &operator>>=(unsigned int shift) > > base-commit: bd266aa3405d3aea20b407b27e52482b02146030 > prerequisite-patch-id: cd23c4b11eb03f4ed3a6ce924dc40b2122c3d996 > prerequisite-patch-id: 9134d77756d5822a87717f016e7f0b0f0b11caf2 > prerequisite-patch-id: 76085046643e01f0e288e8d1eab0eae4c3cd653e > prerequisite-patch-id: f2029084f2d806ad9587d3a274beb6e42b63fb23 > -- > Regards, > > Laurent Pinchart >
diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h index 0270651a0ef7..0af629e69d56 100644 --- a/include/libcamera/internal/vector.h +++ b/include/libcamera/internal/vector.h @@ -120,42 +120,42 @@ public: Vector &operator+=(const Vector &other) { - return apply([](T a, T b) { return a + b; }, other); + return apply(std::plus<>{}, other); } Vector &operator+=(T scalar) { - return apply([](T a, T b) { return a + b; }, scalar); + return apply(std::plus<>{}, scalar); } Vector &operator-=(const Vector &other) { - return apply([](T a, T b) { return a - b; }, other); + return apply(std::minus<>{}, other); } Vector &operator-=(T scalar) { - return apply([](T a, T b) { return a - b; }, scalar); + return apply(std::minus<>{}, scalar); } Vector &operator*=(const Vector &other) { - return apply([](T a, T b) { return a * b; }, other); + return apply(std::multiplies<>{}, other); } Vector &operator*=(T scalar) { - return apply([](T a, T b) { return a * b; }, scalar); + return apply(std::multiplies<>{}, scalar); } Vector &operator/=(const Vector &other) { - return apply([](T a, T b) { return a / b; }, other); + return apply(std::divides<>{}, other); } Vector &operator/=(T scalar) { - return apply([](T a, T b) { return a / b; }, scalar); + return apply(std::divides<>{}, scalar); } Vector &operator>>=(unsigned int shift)
The implementation of operator{+,-,/,*}= uses custom lambdas the std::plus, std::minus, std::multiplies and std::divides standard objects. Replace the manual implementation to simplify the code. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- This patch applies on top of "[PATCH 0/4] libcamera: vector: Add clamp() function". --- include/libcamera/internal/vector.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) base-commit: bd266aa3405d3aea20b407b27e52482b02146030 prerequisite-patch-id: cd23c4b11eb03f4ed3a6ce924dc40b2122c3d996 prerequisite-patch-id: 9134d77756d5822a87717f016e7f0b0f0b11caf2 prerequisite-patch-id: 76085046643e01f0e288e8d1eab0eae4c3cd653e prerequisite-patch-id: f2029084f2d806ad9587d3a274beb6e42b63fb23