From patchwork Fri Oct 23 22:00:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10232 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 E5D9ABDB13 for ; Fri, 23 Oct 2020 22:01:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 746DA61B8D; Sat, 24 Oct 2020 00:01:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qmui/rOy"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3C9BC615D2 for ; Sat, 24 Oct 2020 00:01:11 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C6E5B9BF; Sat, 24 Oct 2020 00:01:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1603490471; bh=6sNVQxqVMn98JdO0K1EO6MlrMIdrAWhOBNeKfwOHVII=; h=From:To:Cc:Subject:Date:From; b=qmui/rOyTaRmAByxffTO4xdBfUQZJfw+2jiTUxmqWW7RXgeIk4Tvg/fDnTGlAVkU7 /2FJAK6c4GJm5g5jzqVh+l/tlzbmv9yiFoz24thAVDwTeMLWQ2cWYBZkSTIfeYl92a uL82mVyd0EZ1YzHCGP24cbYTqxXc/HfUyWFfffuQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 24 Oct 2020 01:00:20 +0300 Message-Id: <20201023220020.22536-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] 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" 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. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- include/libcamera/controls.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 3d7f4b0dc1a7..3b7f3347761e 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -97,6 +97,7 @@ public: #ifndef __DOXYGEN__ template::value && + details::control_type::value && !std::is_same>::value, std::nullptr_t> = nullptr> ControlValue(const T &value)