From patchwork Mon Oct 27 10:53:32 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: 24834 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 7C051C32CE for ; Mon, 27 Oct 2025 10:53:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2B4786075B; Mon, 27 Oct 2025 11:53:40 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="EhBYyKcK"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9AFD060707 for ; Mon, 27 Oct 2025 11:53:36 +0100 (CET) Received: from pb-laptop.local (185.182.215.162.nat.pool.zt.hu [185.182.215.162]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C224516AE for ; Mon, 27 Oct 2025 11:51:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761562308; bh=uBKi+OiywSWkN660kQkejMg0ujB6o+5uVleGg4jD5uA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EhBYyKcKoAoAojckRqzSO+MRRPVnxbF0OHcP17pApmAgglrSMGK+sRZeH9WE3IkLT OTKan+RGdmYD5BG1yaajHsSJq5K/BehNQChc035+lKFvmLaUHoOXHywUuBqePBryju 5Nr3XGkdrvHKEiqVUPJ+1VJy8GFF75xQ5JwzGTSc= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 1/2] libcamera: base: utils: Simplify `enumerate()` Date: Mon, 27 Oct 2025 11:53:32 +0100 Message-ID: <20251027105333.103186-2-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251027105333.103186-1-barnabas.pocze@ideasonboard.com> References: <20251027105333.103186-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" `std::{begin,end}()` support arrays, thus there is no need for a second overload. The only reason it is currently needed is that the trailing return type of the first overload uses `iterable.begin()`, which leads to a substitution failure, so that overload is not considered. So remove the array overload, and let CTAD deduce the `Base` template parameter of `enumerate_adapter`, which will make things work for arrays as well. Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/base/utils.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index cb8caaa9ba..d32bd1cd62 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -355,19 +355,11 @@ private: } /* namespace details */ template -auto enumerate(T &iterable) -> details::enumerate_adapter +auto enumerate(T &iterable) { - return { std::begin(iterable), std::end(iterable) }; + return details::enumerate_adapter{ std::begin(iterable), std::end(iterable) }; } -#ifndef __DOXYGEN__ -template -auto enumerate(T (&iterable)[N]) -> details::enumerate_adapter -{ - return { std::begin(iterable), std::end(iterable) }; -} -#endif - class Duration : public std::chrono::duration { using BaseDuration = std::chrono::duration;