Show a patch.

GET /api/patches/22322/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 22322,
    "url": "https://patchwork.libcamera.org/api/patches/22322/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22322/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20241215230206.11002-3-laurent.pinchart@ideasonboard.com>",
    "date": "2024-12-15T23:02:00",
    "name": "[RFC,2/8] libcamera: base: utils: Add string_view concatenation operators",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "7f56f267ac15b034b7d06d21c46a47c10d3a14cf",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22322/mbox/",
    "series": [
        {
            "id": 4889,
            "url": "https://patchwork.libcamera.org/api/series/4889/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4889",
            "date": "2024-12-15T23:01:58",
            "name": "libcamera: Use std::string_view",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4889/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22322/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22322/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 12977C32F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 15 Dec 2024 23:02:32 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BB31067F32;\n\tMon, 16 Dec 2024 00:02:28 +0100 (CET)",
            "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 DBFF067F1D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Dec 2024 00:02:25 +0100 (CET)",
            "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 499B92C6;\n\tMon, 16 Dec 2024 00:01:49 +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=\"LCpaqpXv\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1734303709;\n\tbh=uauMBSHP1hmbgl27o/OtM059YBY7Ft15XGKnQd3nRuw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=LCpaqpXvmJInQ8Jdbpa/AKzyrJ1nbjwoiZyMOugtBeID6UCAdfkJgF0qb+UnB6Ray\n\tL/2ZSeKBvysgDam19XtC/5yzPlhtIbMFwtQnf+w3oVsp2e1EP/ddQqLYiOEI2HHd8M\n\taa+TldSlwc4Kc7/aavkvLumNqDhS7buXYLcS7lSA=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "Subject": "[RFC PATCH 2/8] libcamera: base: utils: Add string_view\n\tconcatenation operators",
        "Date": "Mon, 16 Dec 2024 01:02:00 +0200",
        "Message-ID": "<20241215230206.11002-3-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.45.2",
        "In-Reply-To": "<20241215230206.11002-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20241215230206.11002-1-laurent.pinchart@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": "The operator+() overloads to concatenate std::string and\nstd::string_view instances have been introduced in C++26 only. Add a\nlocal implementation in utils.cpp, conditioned by a meson check for\navailability in the standard C++ library.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/base/utils.h | 47 ++++++++++++++++++++++++++++++++++\n src/libcamera/base/meson.build | 12 +++++++++\n test/utils.cpp                 | 34 ++++++++++++++++++++++++\n 3 files changed, 93 insertions(+)",
    "diff": "diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h\nindex 780aeda6a0ce732a..dd012fd58501cd8d 100644\n--- a/include/libcamera/base/utils.h\n+++ b/include/libcamera/base/utils.h\n@@ -433,6 +433,53 @@ private:\n template<class CharT, class Traits>\n std::basic_ostream<CharT, Traits> &operator<<(std::basic_ostream<CharT, Traits> &os,\n \t\t\t\t\t      const utils::Duration &d);\n+\n+#if not HAVE_STD_STRING_VIEW_OPERATOR_PLUS\n+template<class CharT, class Traits, class Alloc>\n+std::basic_string<CharT, Traits, Alloc>\n+operator+(const std::basic_string<CharT, Traits, Alloc> &lhs,\n+\t  std::basic_string_view<CharT, Traits> rhs)\n+{\n+\tstd::basic_string<CharT, Traits, Alloc> str;\n+\n+\tstr.reserve(lhs.size() + rhs.size());\n+\tstr.append(lhs);\n+\tstr.append(rhs);\n+\n+\treturn str;\n+}\n+\n+template<class CharT, class Traits, class Alloc>\n+std::basic_string<CharT, Traits, Alloc>\n+operator+(std::basic_string_view<CharT, Traits> lhs,\n+\t  const std::basic_string<CharT, Traits, Alloc> &rhs)\n+{\n+\tstd::basic_string<CharT, Traits, Alloc> str;\n+\n+\tstr.reserve(lhs.size() + rhs.size());\n+\tstr.append(lhs);\n+\tstr.append(rhs);\n+\n+\treturn str;\n+}\n+\n+template<class CharT, class Traits, class Alloc>\n+std::basic_string<CharT, Traits, Alloc>\n+operator+(std::basic_string<CharT, Traits, Alloc> &&lhs,\n+\t  std::basic_string_view<CharT, Traits> rhs)\n+{\n+\treturn std::move(lhs.append(rhs));\n+}\n+\n+template<class CharT, class Traits, class Alloc>\n+std::basic_string<CharT, Traits, Alloc>\n+operator+(std::basic_string_view<CharT, Traits> lhs,\n+\t  std::basic_string<CharT, Traits, Alloc> &&rhs)\n+{\n+\treturn std::move(rhs.insert(0, lhs));\n+}\n+#endif /* HAVE_STD_STRING_VIEW_OPERATOR_PLUS */\n+\n #endif\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/base/meson.build b/src/libcamera/base/meson.build\nindex a742dfdfeb24f9a9..1643d6034921a0cb 100644\n--- a/src/libcamera/base/meson.build\n+++ b/src/libcamera/base/meson.build\n@@ -41,6 +41,18 @@ if libunwind.found()\n     config_h.set('HAVE_UNWIND', 1)\n endif\n \n+if cxx.compiles('''\n+#include <string>\n+#include <string_view>\n+\n+int main()\n+{\n+        std::string s = std::string() + std::string_view();\n+        return s.size();\n+}''', name : 'concatenation of std::string and std::string_view')\n+    config_h.set('HAVE_STD_STRING_VIEW_OPERATOR_PLUS', 1)\n+endif\n+\n libcamera_base_deps = [\n     libatomic,\n     libdw,\ndiff --git a/test/utils.cpp b/test/utils.cpp\nindex d25475cb93b96a0a..29e3c26406b4f72e 100644\n--- a/test/utils.cpp\n+++ b/test/utils.cpp\n@@ -170,6 +170,36 @@ protected:\n \t\treturn TestPass;\n \t}\n \n+\tint testStringView()\n+\t{\n+\t\tstd::string s{ \"Hello\" };\n+\t\tstd::string_view sv{ \"World!\" };\n+\n+\t\tif (s + sv != \"HelloWorld!\") {\n+\t\t\tcerr << \"operator+(const std::string &, std::string_view) test failed\";\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (sv + s != \"World!Hello\") {\n+\t\t\tcerr << \"operator+(std::string_view, const std::string &) test failed\";\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (std::move(s) + sv != \"HelloWorld!\") {\n+\t\t\tcerr << \"operator+(std::string &&, std::string_view) test failed\";\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\ts = \"Hello\";\n+\n+\t\tif (sv + std::move(s) != \"World!Hello\") {\n+\t\t\tcerr << \"operator+(std::string_view, std::string &&) test failed\";\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+\n \tint run()\n \t{\n \t\t/* utils::hex() test. */\n@@ -307,6 +337,10 @@ protected:\n \t\tif (testDuration() != TestPass)\n \t\t\treturn TestFail;\n \n+\t\t/* std::string_view operator+() test. */\n+\t\tif (testStringView() != TestPass)\n+\t\t\treturn TestFail;\n+\n \t\treturn TestPass;\n \t}\n };\n",
    "prefixes": [
        "RFC",
        "2/8"
    ]
}