libcamera: base: utils: Fix namespace of operator<< for Duration

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: 5055ca747c ("libcamera: utils: Add helper class for std::chrono::duration")
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Barnabás Pőcze
2026-01-15 11:54:55 +01:00
parent f7417c38e4
commit 79c31f0707
2 changed files with 6 additions and 6 deletions

View File

@@ -421,10 +421,10 @@ scope_exit(EF) -> scope_exit<EF>;
#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 */

View File

@@ -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 */