summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-15 15:30:48 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-16 18:23:43 +0200
commita2f095947f847cb7d3f058a74514109928b1df9f (patch)
tree1f0acdd864813b819b2ad97e916e87d45d1db892
parentf388aa7041d90cbc957e33ff90a5122a3c5237e6 (diff)
libcamera: utils: Implement C++14 make_unique<>()
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
-rw-r--r--src/libcamera/include/utils.h13
1 files changed, 13 insertions, 0 deletions
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 <memory>
+
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+namespace libcamera::utils {
+
+/* C++11 doesn't provide std::make_unique */
+template<typename T, typename... Args>
+std::unique_ptr<T> make_unique(Args&&... args)
+{
+ return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
+}
+
+} /* namespace libcamera::utils */
+
#endif /* __LIBCAMERA_UTILS_H__ */