From patchwork Thu Jan 15 11:16:28 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: 25813 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 037BABDCBF for ; Thu, 15 Jan 2026 11:16:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E7B3C61FC7; Thu, 15 Jan 2026 12:16:34 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="v27YSQ6k"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DCEDF61F84 for ; Thu, 15 Jan 2026 12:16:32 +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 754B84D3 for ; Thu, 15 Jan 2026 12:16:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768475765; bh=aFssBQ4ulwikszOYeI0WUH0iFsVXXcpXGOTy9DPams8=; h=From:To:Subject:Date:From; b=v27YSQ6kBXzp0VFdCcC2S21ElcZIkBT2yDxkwYhaFG9IQ0QLpI1qR4Dlndv+kFA9O gIU8I+cnhYG9P/N4hGGEcZgmE+Hwl5ITy6t0KjiS5ZyUEZHMt3ws8ZHf/XDh4TAm1Q AEZGR2fQs3A3D/BckOe3RjxSANf0LsQviNMwWI+o= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 1/3] libcamera: base: utils: Simplify `operator<<` for `Duration` Date: Thu, 15 Jan 2026 12:16:28 +0100 Message-ID: <20260115111630.1892890-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 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" There is no real need for a function template. It is not defined in a header file, so it has limited availability, and there exists only a single instantion. So convert it to use `std::ostream` directly, like most `operator<<` in the code base. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/base/utils.h | 4 +--- src/libcamera/base/utils.cpp | 11 ++--------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index 0b7407f77..6ce1ace43 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -426,9 +426,7 @@ scope_exit(EF) -> scope_exit; } /* namespace utils */ #ifndef __DOXYGEN__ -template -std::basic_ostream &operator<<(std::basic_ostream &os, - const utils::Duration &d); +std::ostream &operator<<(std::ostream &os, const utils::Duration &d); #endif } /* namespace libcamera */ diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp index 65d9181c9..2c3f2b7e6 100644 --- a/src/libcamera/base/utils.cpp +++ b/src/libcamera/base/utils.cpp @@ -658,11 +658,9 @@ void ScopeExitActions::release() } /* namespace utils */ #ifndef __DOXYGEN__ -template -std::basic_ostream &operator<<(std::basic_ostream &os, - const utils::Duration &d) +std::ostream &operator<<(std::ostream &os, const utils::Duration &d) { - std::basic_ostringstream s; + std::ostringstream s; s.flags(os.flags()); s.imbue(os.getloc()); @@ -671,11 +669,6 @@ std::basic_ostream &operator<<(std::basic_ostream s << d.get() << "us"; return os << s.str(); } - -template -std::basic_ostream> & -operator<< >(std::basic_ostream> &os, - const utils::Duration &d); #endif } /* namespace libcamera */