From patchwork Tue Jan 6 16:57:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 25634 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id E30B2BDCBF for ; Tue, 6 Jan 2026 16:58:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CEB8661FC4; Tue, 6 Jan 2026 17:58:03 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ABelmhwS"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EBD8161FA0 for ; Tue, 6 Jan 2026 17:57:58 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DAC6D1340; Tue, 6 Jan 2026 17:57:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1767718658; bh=3Wv7dFN/RmtdtVgzwW1D/1+hp3VVAILss1MVsZ07raU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ABelmhwSBjFGKJl8iPRMSxHhGMmdZGhAPEWM+cxY6fxIP3p65LiZ57a5IG5ar+dLH ceZNM/yRyA2uhF75uRyttRs6LXXIYVFVdU5cqjgQBAdLOQqCrdm8qt7kuvKScjwrFd V/SdGkoCBE59pBZAtiE7yJA9YDDuSaWeiWlyLWYA= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Paul Elder , Kieran Bingham Subject: [PATCH v4 04/22] libcamera: base: cxx20: Add `type_identity{,_t}` Date: Tue, 6 Jan 2026 17:57:36 +0100 Message-ID: <20260106165754.1759831-5-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260106165754.1759831-1-barnabas.pocze@ideasonboard.com> References: <20260106165754.1759831-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" `type_identity_t` can be used to force non-deduced contexts in templates, such as: void f(T x, type_identity_t y) when calling `f(1u, 2)`, without `type_identity_t`, the compiler could not unambiguously deduce `T` (unsigned int vs int). However, with `type_identity_t`, the type of the argument passed to `y` will not be used to deduce `T`, only the argument passed to `x`. See https://en.cppreference.com/w/cpp/types/type_identity Signed-off-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- include/libcamera/base/internal/cxx20.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/libcamera/base/internal/cxx20.h b/include/libcamera/base/internal/cxx20.h index 70a43f83c..1f4caf56f 100644 --- a/include/libcamera/base/internal/cxx20.h +++ b/include/libcamera/base/internal/cxx20.h @@ -15,4 +15,28 @@ namespace libcamera::internal::cxx20 { +/** + * \internal + * \brief std::type_identity + * + * Implementation of std::type_identity for C++17. + */ +template struct type_identity { + /** + * \internal + * \brief std::type_identity::type + * + * Type alias matching the template parameter. + */ + using type = T; +}; + +/** + * \internal + * \brief std::type_identity_t + * + * Implementation of std::type_identity_t for C++17. + */ +template using type_identity_t = typename type_identity::type; + } /* namespace libcamera::internal::cxx20 */