From 29c09e3ab6c18c649d8510a1faee6c5a2b52c04a Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 2 Aug 2022 22:47:05 +0300 Subject: libcamera: v4l2_pixelformat: Implement std::hash specialization Inject a specialization of std::hash<> for the V4L2PixelFormat class in the std namespace to make it possible to store instances of the class in the std::unordered_map and std::unordered_set containers. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Signed-off-by: Jacopo Mondi Tested-by: Paul Elder --- include/libcamera/internal/v4l2_pixelformat.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h index d5400f90..34d283db 100644 --- a/include/libcamera/internal/v4l2_pixelformat.h +++ b/include/libcamera/internal/v4l2_pixelformat.h @@ -8,6 +8,7 @@ #pragma once +#include #include #include #include @@ -55,3 +56,15 @@ private: std::ostream &operator<<(std::ostream &out, const V4L2PixelFormat &f); } /* namespace libcamera */ + +namespace std { + +template<> +struct hash { + size_t operator()(libcamera::V4L2PixelFormat const &format) const noexcept + { + return format.fourcc(); + } +}; + +} /* namespace std */ -- cgit v1.2.1