From patchwork Tue Jan 15 15:18:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 239 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F51F60C8A for ; Tue, 15 Jan 2019 16:18:55 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 29DA59DC for ; Tue, 15 Jan 2019 16:18:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1547565535; bh=EeHx7F4G3g+r7yLlZuozFoIBtaBP7srRW00d+LqYPTs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=evye7kJuD2rThzwK6qlpYRxI63CoO+bEGaYgbOw8sMgPMBx7oDdk5JMLAPNUdmAte ql1y5NSR8NgQeZ3sdmfCFoBE8Mmh8WMjNg0/mbEfcgWXxL1zjsgOFm9IDvzWk8djMr /rXIVWytlIxWIuD6qhmbKkp3w6IuOAKEE8cf6FqY= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 15 Jan 2019 17:18:48 +0200 Message-Id: <20190115151849.1547-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190115151849.1547-1-laurent.pinchart@ideasonboard.com> References: <20190115151849.1547-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 7/8] libcamera: utils: Implement C++14 make_unique<>() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jan 2019 15:18:55 -0000 C++14 introduces std::make_unique<>() that makes it easier to initialize unique_ptr<> instances. As libcamera is limited to C++11, implement our own version of the function in the libcamera::utils namespace. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/include/utils.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h index 3ffa6f4ea591..a2e450b35372 100644 --- a/src/libcamera/include/utils.h +++ b/src/libcamera/include/utils.h @@ -7,6 +7,19 @@ #ifndef __LIBCAMERA_UTILS_H__ #define __LIBCAMERA_UTILS_H__ +#include + #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) +namespace libcamera::utils { + +/* C++11 doesn't provide std::make_unique */ +template +std::unique_ptr make_unique(Args&&... args) +{ + return std::unique_ptr(new T(std::forward(args)...)); +} + +} /* namespace libcamera::utils */ + #endif /* __LIBCAMERA_UTILS_H__ */