[{"id":36571,"web_url":"https://patchwork.libcamera.org/comment/36571/","msgid":"<176190953951.567526.9515084240726395859@ping.linuxembedded.co.uk>","date":"2025-10-31T11:18:59","subject":"Re: [RFC PATCH v3 04/22] libcamera: base: cxx20: Add\n\t`type_identity{, _t}`","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2025-10-30 16:57:58)\n> `type_identity_t` can be used to force non-deduced contexts\n> in templates, such as:\n> \n>   void f(T x, type_identity_t<T> y)\n> \n> when calling `f(1u, 2)`, without `type_identity_t`, the compiler\n> could not unambiguously deduce `T` (unsigned int vs int). However,\n> with `type_identity_t`, the type of the argument passed to `y`\n> will not be used to deduce `T`, only the argument passed to `x`.\n> \n> See https://en.cppreference.com/w/cpp/types/type_identity\n> \n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\nI'd usually skip over patches with two RB tags already but this one is\ninteresting to me as I've been spending more time with templates lately\n- and so I think this is a nice addition.\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  include/libcamera/base/internal/cxx20.h | 24 ++++++++++++++++++++++++\n>  1 file changed, 24 insertions(+)\n> \n> diff --git a/include/libcamera/base/internal/cxx20.h b/include/libcamera/base/internal/cxx20.h\n> index 70a43f83c9..1f4caf56f8 100644\n> --- a/include/libcamera/base/internal/cxx20.h\n> +++ b/include/libcamera/base/internal/cxx20.h\n> @@ -15,4 +15,28 @@\n>  \n>  namespace libcamera::internal::cxx20 {\n>  \n> +/**\n> + * \\internal\n> + * \\brief std::type_identity\n> + *\n> + * Implementation of std::type_identity for C++17.\n> + */\n> +template<typename T> struct type_identity {\n> +       /**\n> +        * \\internal\n> +        * \\brief std::type_identity<T>::type\n> +        *\n> +        * Type alias matching the template parameter.\n> +        */\n> +       using type = T;\n> +};\n> +\n> +/**\n> + * \\internal\n> + * \\brief std::type_identity_t\n> + *\n> + * Implementation of std::type_identity_t for C++17.\n> + */\n> +template<typename T> using type_identity_t = typename type_identity<T>::type;\n> +\n>  } /* namespace libcamera::internal::cxx20 */\n> -- \n> 2.51.1\n>","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 23C25C3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 Oct 2025 11:19:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E8FA86098A;\n\tFri, 31 Oct 2025 12:19:04 +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 6FEAF600CC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Oct 2025 12:19:03 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 49B0316A8;\n\tFri, 31 Oct 2025 12:17:12 +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=\"buq9dipx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761909432;\n\tbh=lz2FXhe9Q6GXBnIveWTbw9VDMY3XY6CUe3STaRetLWw=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=buq9dipxYV6anzP0kpjN6tV1gGO7n2x4uV7POneAHDcvYRnCAb9C149rXzoe2Mie6\n\tue3Bc23E7WyVTfcC0V42avkDsN/QV9xSGgODmGoq/pad37Iz1xD5nKDlZn7j1zV7ED\n\tDINZjHUsvDkKSzek29vS30Zua0Vy2wYkVs6vNS5g=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251030165816.1095180-5-barnabas.pocze@ideasonboard.com>","References":"<20251030165816.1095180-1-barnabas.pocze@ideasonboard.com>\n\t<20251030165816.1095180-5-barnabas.pocze@ideasonboard.com>","Subject":"Re: [RFC PATCH v3 04/22] libcamera: base: cxx20: Add\n\t`type_identity{, _t}`","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 31 Oct 2025 11:18:59 +0000","Message-ID":"<176190953951.567526.9515084240726395859@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]