From 79c31f07075619c2087b83755b4a32393113b963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 15 Jan 2026 11:54:55 +0100 Subject: [PATCH] libcamera: base: utils: Fix namespace of `operator<<` for `Duration` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order for ADL to find the function, it must be in the namespace of any of its arguments. Previously, however, that was not the case, and it has only really worked by accident and could be easily made to fail by introducing other `operator<<` overloads. For example, a user of this function in `libcamera::ipa` would no longer compile after introducing an `operator<<` into the `libcamera::ipa` namespace as that would essentially hide this overload, and without ADL it would not be found. So move the function into the `utils` namespace. Fixes: 5055ca747c4c ("libcamera: utils: Add helper class for std::chrono::duration") Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/base/utils.h | 6 +++--- src/libcamera/base/utils.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index 198cf152..4373bc20 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -421,10 +421,10 @@ scope_exit(EF) -> scope_exit; #endif /* __DOXYGEN__ */ -} /* namespace utils */ - #ifndef __DOXYGEN__ -std::ostream &operator<<(std::ostream &os, const utils::Duration &d); +std::ostream &operator<<(std::ostream &os, const Duration &d); #endif +} /* namespace utils */ + } /* namespace libcamera */ diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp index 2c3f2b7e..42a51609 100644 --- a/src/libcamera/base/utils.cpp +++ b/src/libcamera/base/utils.cpp @@ -655,10 +655,8 @@ void ScopeExitActions::release() actions_.clear(); } -} /* namespace utils */ - #ifndef __DOXYGEN__ -std::ostream &operator<<(std::ostream &os, const utils::Duration &d) +std::ostream &operator<<(std::ostream &os, const Duration &d) { std::ostringstream s; @@ -671,4 +669,6 @@ std::ostream &operator<<(std::ostream &os, const utils::Duration &d) } #endif +} /* namespace utils */ + } /* namespace libcamera */