From patchwork Thu Oct 30 16:57:58 2025 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: 24907 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 8A3F5C32D4 for ; Thu, 30 Oct 2025 16:58:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6CB0B60990; Thu, 30 Oct 2025 17:58:28 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="b+QMKywT"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A97DB608DC for ; Thu, 30 Oct 2025 17:58:21 +0100 (CET) Received: from pb-laptop.local (185.221.140.239.nat.pool.zt.hu [185.221.140.239]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8A62D1E33; Thu, 30 Oct 2025 17:56:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761843391; bh=WtclvwcEGVeNjqk9NUASUu+f9QRky4OsOLH0IVX3Lns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b+QMKywT2PTtroazp8hhsNWYJxSd57XuxXiFuTNtaWWWt6nnHXzHoe0ZpSNUWLA4Z zRqu+uvzJItc0mj8F/odD8DCVHNFnKkvzx0Er2xmOf1mFIrs3MMrrloc6IL0Ds9BW4 WOrPA5ns5Hf6DOgUQGW6KjJ+aQYYMtGcIC6bmUPM= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Paul Elder Subject: [RFC PATCH v3 04/22] libcamera: base: cxx20: Add `type_identity{, _t}` Date: Thu, 30 Oct 2025 17:57:58 +0100 Message-ID: <20251030165816.1095180-5-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251030165816.1095180-1-barnabas.pocze@ideasonboard.com> References: <20251030165816.1095180-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 70a43f83c9..1f4caf56f8 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 */