C++ Utilities  4.6.1
Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities
memory.h
Go to the documentation of this file.
1 #ifndef MEMORY_H
2 #define MEMORY_H
3 
4 #include <memory>
5 
7 
8 #if __cplusplus <= 201103L
9 #define __cpp_lib_make_unique 201304
10 namespace std {
11  template<typename _Tp>
12  struct _MakeUniq
13  { typedef unique_ptr<_Tp> __single_object; };
14 
15  template<typename _Tp>
16  struct _MakeUniq<_Tp[]>
17  { typedef unique_ptr<_Tp[]> __array; };
18 
19  template<typename _Tp, size_t _Bound>
20  struct _MakeUniq<_Tp[_Bound]>
21  { struct __invalid_type { }; };
22 
24  template<typename _Tp, typename... _Args>
25  inline typename _MakeUniq<_Tp>::__single_object
26  make_unique(_Args&&... __args)
27  { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
28 
30  template<typename _Tp>
31  inline typename _MakeUniq<_Tp>::__array
32  make_unique(size_t __num)
33  { return unique_ptr<_Tp>(new typename remove_extent<_Tp>::type[__num]()); }
34 
36  template<typename _Tp, typename... _Args>
37  inline typename _MakeUniq<_Tp>::__invalid_type
38  make_unique(_Args&&...) = delete;
39 }
40 #endif
41 
43 
44 #endif // MEMORY_H
45 
STL namespace.