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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Tested-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
committed by
Jacopo Mondi
parent
b7ca378b65
commit
29c09e3ab6
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <ostream>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
@@ -55,3 +56,15 @@ private:
|
||||
std::ostream &operator<<(std::ostream &out, const V4L2PixelFormat &f);
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
namespace std {
|
||||
|
||||
template<>
|
||||
struct hash<libcamera::V4L2PixelFormat> {
|
||||
size_t operator()(libcamera::V4L2PixelFormat const &format) const noexcept
|
||||
{
|
||||
return format.fourcc();
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace std */
|
||||
|
||||
Reference in New Issue
Block a user