@@ -423,10 +423,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 */
@@ -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 */
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 <barnabas.pocze@ideasonboard.com> --- include/libcamera/base/utils.h | 6 +++--- src/libcamera/base/utils.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)