From patchwork Sun Oct 25 16:04:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10236 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 EE47BBDB13 for ; Sun, 25 Oct 2020 16:04:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CB63F61E4B; Sun, 25 Oct 2020 17:04:44 +0100 (CET) Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 878E861E01 for ; Sun, 25 Oct 2020 17:04:42 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 8985F240003; Sun, 25 Oct 2020 16:04:41 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Sun, 25 Oct 2020 17:04:21 +0100 Message-Id: <20201025160434.25664-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201025160434.25664-1-jacopo@jmondi.org> References: <20201025160434.25664-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 01/14] libcamera: controls: Disable ControlValue construction from unsupported T 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Laurent Pinchart The ControlValue constructor for non-array values is a template function that participates in overload resolution for all T types that are not Span or std::string. Other T types that are not supported then result in a compilation error. This causes issues when calling an overloaded function that can accept both a ControlValue and a Span with an std::array parameter. The first overload will be resolved using implicit construction of a ControlValue from the std::array, while the second overload will be resolved using implicit construction of a Span from the std::array. This results in a compilation error due to an ambiguous function call. The first overload is invalid, selecting it would result in a compilation error in the ControlValue constructor, as the ControlValue constructor doesn't support std::array for type T. The compiler can't know about that, as overload resolution happens earlier. To fix it, we can disable the ControlValue constructor for unsupported types T, moving the type check from compilation of the function to overload resolution. The constructor will not participate in overload resolution, and the call won't be ambiguous. The end result is the same for unsupported types, compilation will fail. Reviewed-by: Jacopo Mondi Signed-off-by: Laurent Pinchart Acked-by: Kieran Bingham --- include/libcamera/controls.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 80944efc133a..a556328cd188 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -96,6 +96,7 @@ public: #ifndef __DOXYGEN__ template::value && + details::control_type::value && !std::is_same>::value, std::nullptr_t> = nullptr> ControlValue(const T &value)