DSA - Data Structures and Algorithms
Loading...
Searching...
No Matches
memory.h
Go to the documentation of this file.
1
11
12#ifndef MEMORY_H
13#define MEMORY_H
14
15#include <memory>
16
17namespace dsa
18{
19 // custom implementation of make_unique for c++11
20#if __cplusplus < 201402L
21
22 // make_unique for single objects
23
35 template<typename T, typename... Args>
36 auto make_unique(Args&&... args) -> typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type
37 {
38 return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
39 }
40
41#else // c++14 and newer
42
43 // use original implementation of std::make_unique when newer c++ version is used
44 // and prevent clang-tidy warning
45 // NOLINTNEXTLINE(misc-unused-using-decls)
46 using std::make_unique;
47
48#endif
49}
50
51#endif // !MEMORY_H
auto make_unique(Args &&... args) -> typename std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type
Creates T type object and wraps it std::unique_ptr.
Definition memory.h:36