From patchwork Sat Feb 29 16:42:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2927 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 62BBA62787 for ; Sat, 29 Feb 2020 17:43:25 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0217F33E for ; Sat, 29 Feb 2020 17:43:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1582994605; bh=yILmkhNrTwHmEcsjNAazHHfb3IUGlKb786I96spDtdI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DKjyIwRfOwo7dCn8k0hyPD63igLed/MFwCijiGE0VJX+Rrd9rsQd6UuAapm/7m5iB QNcWW+7B/aN3ENA3fkaoGnK60iIFaTsAJJHsKb4t57yh/fkoDQUiRkzIMwWzenGfCB JBRVFkHMTvCfmw9fiZRqDv84eLiyoD/VSmSLqD4E= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 29 Feb 2020 18:42:32 +0200 Message-Id: <20200229164254.23604-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200229164254.23604-1-laurent.pinchart@ideasonboard.com> References: <20200229164254.23604-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 09/31] libcamera: controls: Decouple control and value type in ControlList::set() 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-List-Received-Date: Sat, 29 Feb 2020 16:43:25 -0000 The ControlList::set() method takes a reference to a Control, and requires the value to be a reference to T. This prevents the set() method to be used with value types that are convertible to T, and in particular with std::array or std::vector values types when the Control type will be a Span<> to support compound controls. Fix this by decoupling the control type and value type in the template parameters. The compiler will still catch invalid conversions, including cases where constructor a T from the value type is explicit. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/controls.h | 4 ++-- src/libcamera/controls.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 9f8a9031bd74..9d93064c11b2 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -223,8 +223,8 @@ public: return val->get(); } - template - void set(const Control &ctrl, const T &value) + template + void set(const Control &ctrl, const V &value) { ControlValue *val = find(ctrl.id()); if (!val) diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index f632d60adc8b..a136ebd2653b 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -735,7 +735,7 @@ bool ControlList::contains(unsigned int id) const */ /** - * \fn template void ControlList::set(const Control &ctrl, const T &value) + * \fn template void ControlList::set(const Control &ctrl, const V &value) * \brief Set the control \a ctrl value to \a value * \param[in] ctrl The control * \param[in] value The control value