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:
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user