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>
This commit is contained in:
parent
f388aa7041
commit
a2f095947f
1 changed files with 13 additions and 0 deletions
|
@ -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__ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue