From a2f095947f847cb7d3f058a74514109928b1df9f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 15 Jan 2019 15:30:48 +0200 Subject: libcamera: utils: Implement C++14 make_unique<>() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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(+) (limited to 'src') diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h index 3ffa6f4e..a2e450b3 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__ */ -- cgit v1.2.1