{"id":20078,"url":"https://patchwork.libcamera.org/api/1.1/patches/20078/?format=json","web_url":"https://patchwork.libcamera.org/patch/20078/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240520040249.209200-1-pobrn@protonmail.com>","date":"2024-05-20T04:02:50","name":"[v1] libcamera: yaml_parser: Make default value templated in `get()`","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"94f0ade73e127aa07120e851b30347738ba1524b","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/1.1/people/133/?format=json","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20078/mbox/","series":[{"id":4319,"url":"https://patchwork.libcamera.org/api/1.1/series/4319/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4319","date":"2024-05-20T04:02:50","name":"[v1] libcamera: yaml_parser: Make default value templated in `get()`","version":1,"mbox":"https://patchwork.libcamera.org/series/4319/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20078/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20078/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 EE6CEBD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 May 2024 04:03:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0C37D6347F;\n\tMon, 20 May 2024 06:03:00 +0200 (CEST)","from mail-40133.protonmail.ch (mail-40133.protonmail.ch\n\t[185.70.40.133])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 068AD6346B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 May 2024 06:02:58 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"I6FSYUJH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1716177777; x=1716436977;\n\tbh=t8rTyrVK76NAH6TBaWUfsi+EvsZbnNeIQ3X9uTp7Cvo=;\n\th=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date:\n\tSubject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector;\n\tb=I6FSYUJHeUWTfaQrXKfWy/LU2Fwsnl5KJCFX2cpDX4aHdA0nsqDXP3BjnwU6xAQMX\n\tQOL5EkIZgbsOi2oV4k2KSTInCDI4GbUbUNRBUUw1xnVd92vmL0hJxQoUeVdYOuSO8F\n\tNVJQ1FoHzABXEzxYiOa+rg5cqDPMobS5uttWCY88ceWcNf/BCu1wbw9QHuaekzhb1g\n\tDaX3FOYF1zUck5kxiqllkmHIhqgATF14AuJR3/ZGOJECGyGEfH4Pji36xR/6lauE56\n\t+G/ULBuj/dmxJ9XO0iQvQAf2l/16Xb5T9TfeJPdfyF1pIfE/koU5BxViT7N6TXP4S1\n\tnKtJZ7AzoU7IQ==","Date":"Mon, 20 May 2024 04:02:50 +0000","To":"libcamera-devel@lists.libcamera.org","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Subject":"[PATCH v1] libcamera: yaml_parser: Make default value templated in\n\t`get()`","Message-ID":"<20240520040249.209200-1-pobrn@protonmail.com>","Feedback-ID":"20568564:user:proton","X-Pm-Message-ID":"fac5e61cc0ed682f9bdc3a4d1f5ea9541e820778","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","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":"This way the construction of the default value of type `T`\ncan be delayed until it is really needed, which is useful,\nfor example when `T == std::string`, as the default value\nstring would always be constructed otherwise.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n---\n include/libcamera/internal/yaml_parser.h | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)","diff":"diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\nindex b6979d73..3ac27e06 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -179,10 +179,10 @@ public:\n #endif\n \tstd::optional<T> get() const;\n \n-\ttemplate<typename T>\n-\tT get(const T &defaultValue) const\n+\ttemplate<typename T, typename U>\n+\tT get(U &&defaultValue) const\n \t{\n-\t\treturn get<T>().value_or(defaultValue);\n+\t\treturn get<T>().value_or(std::forward<U>(defaultValue));\n \t}\n \n #ifndef __DOXYGEN__\n","prefixes":["v1"]}