Patch Detail
Show a patch.
GET /api/1.1/patches/22979/?format=api
{ "id": 22979, "url": "https://patchwork.libcamera.org/api/1.1/patches/22979/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22979/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250319161152.63625-2-stefan.klug@ideasonboard.com>", "date": "2025-03-19T16:11:06", "name": "[v2,01/17] libcamera: matrix: Replace SFINAE with static_asserts", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "255a558f88a393cb84b9339774dde663b246c251", "submitter": { "id": 184, "url": "https://patchwork.libcamera.org/api/1.1/people/184/?format=api", "name": "Stefan Klug", "email": "stefan.klug@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22979/mbox/", "series": [ { "id": 5071, "url": "https://patchwork.libcamera.org/api/1.1/series/5071/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5071", "date": "2025-03-19T16:11:05", "name": "Some rkisp1 awb improvements", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5071/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22979/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22979/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 20986C32FE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 19 Mar 2025 16:12:02 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CCBB868950;\n\tWed, 19 Mar 2025 17:12:01 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F24CD68945\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Mar 2025 17:11:59 +0100 (CET)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:760:e5ca:4814:99c7])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 04DBE8FA;\n\tWed, 19 Mar 2025 17:10:16 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"UsT7bEDo\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1742400617;\n\tbh=oFIl/d/8UPVKsZ0KLKeqRsE/24LTr+AMeld281uk9Cw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=UsT7bEDoBvpHt1cIj7RiEusG2Ettnm1gbXeJaOLl6hLSpvzec+dskJzdsBe58RseC\n\thAG1m+y25gcs03vS6034jYW8AysI7X3WETTquMpIUgMkAvDUPczb8Jrv4dO5gfDpGj\n\ts5wSkx3D1oVCM971lJLHP/ObbVt5D8jA2Z8jfyo8=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>", "Subject": "[PATCH v2 01/17] libcamera: matrix: Replace SFINAE with\n\tstatic_asserts", "Date": "Wed, 19 Mar 2025 17:11:06 +0100", "Message-ID": "<20250319161152.63625-2-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20250319161152.63625-1-stefan.klug@ideasonboard.com>", "References": "<20250319161152.63625-1-stefan.klug@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "SFINAE is difficult to read and not needed in these cases. Replace it\nwith static_asserts. The idea came from [1] where it is stated:\n\n\"The use of enable_if seems misguided to me. SFINAE is useful for the\nsituation where we consider multiple candidates for something (overloads\nor class template specializations) and try to choose the correct one,\nwithout causing compilation to fail.\"\n\n[1]: https://stackoverflow.com/questions/62109526/c-friend-template-that-use-sfinae\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\n---\n\nChanges in v2:\n- Added this patch\n---\n include/libcamera/internal/matrix.h | 42 ++++++++---------------------\n 1 file changed, 11 insertions(+), 31 deletions(-)", "diff": "diff --git a/include/libcamera/internal/matrix.h b/include/libcamera/internal/matrix.h\nindex a055e6926c94..8399be583f28 100644\n--- a/include/libcamera/internal/matrix.h\n+++ b/include/libcamera/internal/matrix.h\n@@ -19,14 +19,11 @@ namespace libcamera {\n \n LOG_DECLARE_CATEGORY(Matrix)\n \n-#ifndef __DOXYGEN__\n-template<typename T, unsigned int Rows, unsigned int Cols,\n-\t std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>\n-#else\n template<typename T, unsigned int Rows, unsigned int Cols>\n-#endif /* __DOXYGEN__ */\n class Matrix\n {\n+\tstatic_assert(std::is_arithmetic_v<T>, \"Matrix type must be arithmetic\");\n+\n public:\n \tMatrix()\n \t{\n@@ -78,13 +75,10 @@ public:\n \t\treturn Span<T, Cols>{ &data_.data()[i * Cols], Cols };\n \t}\n \n-#ifndef __DOXYGEN__\n-\ttemplate<typename U, std::enable_if_t<std::is_arithmetic_v<U>>>\n-#else\n \ttemplate<typename U>\n-#endif /* __DOXYGEN__ */\n-\tMatrix<T, Rows, Cols> &operator*=(U d)\n+\tconstexpr Matrix<T, Rows, Cols> &operator*=(U d)\n \t{\n+\t\tstatic_assert(std::is_arithmetic_v<U>, \"Multiplier must be arithmetic\");\n \t\tfor (unsigned int i = 0; i < Rows * Cols; i++)\n \t\t\tdata_[i] *= d;\n \t\treturn *this;\n@@ -94,14 +88,10 @@ private:\n \tstd::array<T, Rows * Cols> data_;\n };\n \n-#ifndef __DOXYGEN__\n-template<typename T, typename U, unsigned int Rows, unsigned int Cols,\n-\t std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>\n-#else\n template<typename T, typename U, unsigned int Rows, unsigned int Cols>\n-#endif /* __DOXYGEN__ */\n-Matrix<U, Rows, Cols> operator*(T d, const Matrix<U, Rows, Cols> &m)\n+constexpr Matrix<U, Rows, Cols> operator*(T d, const Matrix<U, Rows, Cols> &m)\n {\n+\tstatic_assert(std::is_arithmetic_v<T>, \"Multiplier must be arithmetic\");\n \tMatrix<U, Rows, Cols> result;\n \n \tfor (unsigned int i = 0; i < Rows; i++) {\n@@ -112,27 +102,17 @@ Matrix<U, Rows, Cols> operator*(T d, const Matrix<U, Rows, Cols> &m)\n \treturn result;\n }\n \n-#ifndef __DOXYGEN__\n-template<typename T, typename U, unsigned int Rows, unsigned int Cols,\n-\t std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>\n-#else\n template<typename T, typename U, unsigned int Rows, unsigned int Cols>\n-#endif /* __DOXYGEN__ */\n-Matrix<U, Rows, Cols> operator*(const Matrix<U, Rows, Cols> &m, T d)\n+constexpr Matrix<U, Rows, Cols> operator*(const Matrix<U, Rows, Cols> &m, T d)\n {\n+\tstatic_assert(std::is_arithmetic_v<T>, \"Multiplier must be arithmetic\");\n \treturn d * m;\n }\n \n-#ifndef __DOXYGEN__\n-template<typename T,\n-\t unsigned int R1, unsigned int C1,\n-\t unsigned int R2, unsigned int C2,\n-\t std::enable_if_t<C1 == R2> * = nullptr>\n-#else\n-template<typename T, unsigned int R1, unsigned int C1, unsigned int R2, unsigned in C2>\n-#endif /* __DOXYGEN__ */\n-Matrix<T, R1, C2> operator*(const Matrix<T, R1, C1> &m1, const Matrix<T, R2, C2> &m2)\n+template<typename T, unsigned int R1, unsigned int C1, unsigned int R2, unsigned int C2>\n+constexpr Matrix<T, R1, C2> operator*(const Matrix<T, R1, C1> &m1, const Matrix<T, R2, C2> &m2)\n {\n+\tstatic_assert(C1 == R2, \"Matrix dimensions must match for multiplication\");\n \tMatrix<T, R1, C2> result;\n \n \tfor (unsigned int i = 0; i < R1; i++) {\n", "prefixes": [ "v2", "01/17" ] }