From e8c194db2a6bd0ac9662d147826ca83b66a99fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 27 Oct 2025 11:30:13 +0100 Subject: [PATCH] libcamera: base: utils: Simplify `enumerate()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `std::{begin,end}()` support C-style 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 cb8caaa9..d32bd1cd 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;