From patchwork Wed Aug 3 11:26:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16951 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C5BD9C3272 for ; Wed, 3 Aug 2022 11:27:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 841C163318; Wed, 3 Aug 2022 13:27:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659526027; bh=bSAXK1NRAX8/nIJWw3M3lAu+FFY1N101Ct9jJTzI8IQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=1VIpY2WO0+b0lfYKDkeGXSTah+aP4XeGHV3TUr4nrUwOqSV/9q2Hotcl3TpipWTzH 1/Riy2qRzGVP4Izx0INBG6FFCw7I1HVdZN++uV5gXHvDGRUDjl2Qf8kOI4vPufBpd1 9LqUSpn59wzPErcAI4ybgqgmrYEX5jwybmFN6258TCGd+yg1pj2YyyolqfJxltZfO9 wyXVtXhFtgK4MxLwLR8KalRFYZOHdbxMf0UHw5VuibosHICp/v2tpnIrK9FRLfPYQ0 2BnLkNdBSrL+0c62mQGQxuhxuKiyne/NDS+WICabvwOQN/lYptR4hMU4yhpWlFf1bX ELb/H9IO8b2oA== Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 53CD36330F for ; Wed, 3 Aug 2022 13:27:06 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 694CD1BF20E; Wed, 3 Aug 2022 11:27:04 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Aug 2022 13:26:38 +0200 Message-Id: <20220803112640.30402-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220803112640.30402-1-jacopo@jmondi.org> References: <20220803112640.30402-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 6/8] libcamera: v4l2_pixelformat: Implement std::hash specialization X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: jozef@mlich.cz, Pavel Machek Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Laurent Pinchart 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 --- 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 d5400f90a67e..34d283db44f4 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 */