Patch Detail
Show a patch.
GET /api/1.1/patches/2713/?format=api
{ "id": 2713, "url": "https://patchwork.libcamera.org/api/1.1/patches/2713/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2713/", "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": "<20200120173816.31829-2-laurent.pinchart@ideasonboard.com>", "date": "2020-01-20T17:38:14", "name": "[libcamera-devel,1/3] libcamera: utils: Add a new make_array() function", "commit_ref": null, "pull_url": null, "state": "rfc", "archived": false, "hash": "f88f18ed656ded248225b3639d0880db4f2f000e", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": { "id": 14, "url": "https://patchwork.libcamera.org/api/1.1/users/14/?format=api", "username": "pinchartl", "first_name": "Laurent", "last_name": "Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "mbox": "https://patchwork.libcamera.org/patch/2713/mbox/", "series": [ { "id": 644, "url": "https://patchwork.libcamera.org/api/1.1/series/644/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=644", "date": "2020-01-20T17:38:13", "name": "Use std::array where applicable", "version": 1, "mbox": "https://patchwork.libcamera.org/series/644/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2713/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2713/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B11F6081F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jan 2020 18:38:21 +0100 (CET)", "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ADE3610D6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jan 2020 18:38:20 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1579541900;\n\tbh=PNjzR3WxiO+vO/1ZND9WK69/l54MBwae0rrQ0g3uCKA=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=Wwx2ObC2g9hPxoZM5YP75ohtDiPc3aBqzIE8l6VH1yHwyW6zjY+Bcb25OJqBcd6Iq\n\t89u5ipoNkQFJbs3SdkcclfgAB3Az2u5GvB72FFgqZiieTVoCFFhjeVjftuNfUH12Dn\n\tKd5cvLNr0LLJk+B6m92XWTm5e2yf7QqrQAGhdk9o=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 20 Jan 2020 19:38:14 +0200", "Message-Id": "<20200120173816.31829-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.24.1", "In-Reply-To": "<20200120173816.31829-1-laurent.pinchart@ideasonboard.com>", "References": "<20200120173816.31829-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 1/3] libcamera: utils: Add a new\n\tmake_array() function", "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>", "X-List-Received-Date": "Mon, 20 Jan 2020 17:38:21 -0000" }, "content": "Add a custom implementation of std::make_array() as defined by the\nlibrary fundamentals TS v2 ([1]). The function is useful to initialize\nstatic arrays without requiring manually specifying the number of\nelements, which could lead to bugs when the specified size is larger\nthan the number of initializers.\n\nThis is an experimental feature in the C++ standard, and while available\nin <experimental/array> in stdlibc++ from g++-6 onwards, it is not\nprovided by libc++.\n\n[1] https://en.cppreference.com/w/cpp/experimental/make_array\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n Documentation/Doxyfile.in | 1 +\n src/libcamera/include/utils.h | 42 +++++++++++++++++++++++++++++++++++\n src/libcamera/utils.cpp | 14 ++++++++++++\n 3 files changed, 57 insertions(+)", "diff": "diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in\nindex 8e6fbdbb92b6..6de59d407e7b 100644\n--- a/Documentation/Doxyfile.in\n+++ b/Documentation/Doxyfile.in\n@@ -877,6 +877,7 @@ EXCLUDE_SYMBOLS = libcamera::BoundMethodArgs \\\n libcamera::BoundMethodPackBase \\\n libcamera::BoundMethodStatic \\\n libcamera::SignalBase \\\n+ *::details::* \\\n std::*\n \n # The EXAMPLE_PATH tag can be used to specify one or more files or directories\ndiff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\nindex e467eb21c518..6e9b9259456a 100644\n--- a/src/libcamera/include/utils.h\n+++ b/src/libcamera/include/utils.h\n@@ -8,12 +8,15 @@\n #define __LIBCAMERA_UTILS_H__\n \n #include <algorithm>\n+#include <array>\n #include <chrono>\n+#include <functional>\n #include <memory>\n #include <ostream>\n #include <string>\n #include <string.h>\n #include <sys/time.h>\n+#include <type_traits>\n \n #define ARRAY_SIZE(a)\t(sizeof(a) / sizeof(a[0]))\n \n@@ -108,6 +111,45 @@ inline _hex hex<uint64_t>(uint64_t value, unsigned int width)\n \n size_t strlcpy(char *dst, const char *src, size_t size);\n \n+namespace details {\n+\n+namespace make_array {\n+\n+\ttemplate<class B>\n+\tstruct negation : std::integral_constant<bool, !bool(B::value)> {};\n+\n+\ttemplate<class...> struct conjunction : std::true_type {};\n+\ttemplate<class B1> struct conjunction<B1> : B1 {};\n+\ttemplate<class B1, class... Bn>\n+\tstruct conjunction<B1, Bn...>\n+\t\t: std::conditional_t<bool(B1::value), conjunction<Bn...>, B1> {};\n+\n+\ttemplate<class> struct is_ref_wrapper : std::false_type {};\n+\ttemplate<class T> struct is_ref_wrapper<std::reference_wrapper<T>> : std::true_type {};\n+\n+\ttemplate<class D, class...>\n+\tstruct return_type_helper {\n+\t\tusing type = D;\n+\t};\n+\ttemplate <class... Types>\n+\tstruct return_type_helper<void, Types...> : std::common_type<Types...> {\n+\t\tstatic_assert(conjunction<negation<is_ref_wrapper<std::decay_t<Types>>>...>::value,\n+\t\t\t \"Types cannot contain reference_wrappers when D is void\");\n+\t};\n+\n+\ttemplate<class D, class... Types>\n+\tusing return_type = std::array<typename return_type_helper<D, Types...>::type,\n+\t\t\t\t sizeof...(Types)>;\n+} /* namespace make_array */\n+\n+} /* namespace details */\n+\n+template<class D = void, class... Types>\n+constexpr details::make_array::return_type<D, Types...> make_array(Types&&... t)\n+{\n+\treturn {std::forward<Types>(t)... };\n+}\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nindex 4beffdab5eb6..b639cfa83d0c 100644\n--- a/src/libcamera/utils.cpp\n+++ b/src/libcamera/utils.cpp\n@@ -199,6 +199,20 @@ size_t strlcpy(char *dst, const char *src, size_t size)\n \treturn strlen(src);\n }\n \n+/**\n+ * \\fn template<class D, class... Types> libcamera::utils::make_array(Types&&... t)\n+ * \\brief Create a std::array with automatic deduction of element type and count\n+ * \\param[in] t The initialization values for the array elements\n+ *\n+ * This function creates and returns an instance of std::array whose size is\n+ * equal to the number of arguments. If the template argument \\a D is void, the\n+ * array element type is deduced from the elements through\n+ * std::common_types_t<Types...>. Otherwise it is set to D. The elements are\n+ * initialized from the corresponding arguments.\n+ *\n+ * \\return A std::array initialized from the arguments\n+ */\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "1/3" ] }