From 461e7d3d73ca4928d9bd132dafede1e3db35a93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 15 Jan 2026 11:51:47 +0100 Subject: [PATCH] libcamera: base: utils: Simplify `operator<<` for `Duration` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 2cb8e0a8..198cf152 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -424,9 +424,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 65d9181c..2c3f2b7e 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 */