Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / common / boost / 1.64.0 / include / boost-1_64 / boost / smart_ptr / make_unique.hpp
1 /*
2 Copyright 2012-2015 Glen Joseph Fernandes
3 (glenjofe@gmail.com)
4
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
7 */
8 #ifndef BOOST_SMART_PTR_MAKE_UNIQUE_HPP
9 #define BOOST_SMART_PTR_MAKE_UNIQUE_HPP
10
11 #include <boost/config.hpp>
12 #include <memory>
13 #include <utility>
14
15 namespace boost {
16 namespace detail {
17
18 template<class T>
19 struct up_if_object {
20     typedef std::unique_ptr<T> type;
21 };
22
23 template<class T>
24 struct up_if_object<T[]> { };
25
26 template<class T, std::size_t N>
27 struct up_if_object<T[N]> { };
28
29 template<class T>
30 struct up_if_array { };
31
32 template<class T>
33 struct up_if_array<T[]> {
34     typedef std::unique_ptr<T[]> type;
35 };
36
37 template<class T>
38 struct up_remove_reference {
39     typedef T type;
40 };
41
42 template<class T>
43 struct up_remove_reference<T&> {
44     typedef T type;
45 };
46
47 template<class T>
48 struct up_remove_reference<T&&> {
49     typedef T type;
50 };
51
52 template<class T>
53 struct up_element { };
54
55 template<class T>
56 struct up_element<T[]> {
57     typedef T type;
58 };
59
60 } /* detail */
61
62 template<class T>
63 inline typename detail::up_if_object<T>::type
64 make_unique()
65 {
66     return std::unique_ptr<T>(new T());
67 }
68
69 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
70 template<class T, class... Args>
71 inline typename detail::up_if_object<T>::type
72 make_unique(Args&&... args)
73 {
74     return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
75 }
76 #endif
77
78 template<class T>
79 inline typename detail::up_if_object<T>::type
80 make_unique(typename detail::up_remove_reference<T>::type&& value)
81 {
82     return std::unique_ptr<T>(new T(std::move(value)));
83 }
84
85 template<class T>
86 inline typename detail::up_if_object<T>::type
87 make_unique_noinit()
88 {
89     return std::unique_ptr<T>(new T);
90 }
91
92 template<class T>
93 inline typename detail::up_if_array<T>::type
94 make_unique(std::size_t size)
95 {
96     return std::unique_ptr<T>(new typename
97         detail::up_element<T>::type[size]());
98 }
99
100 template<class T>
101 inline typename detail::up_if_array<T>::type
102 make_unique_noinit(std::size_t size)
103 {
104     return std::unique_ptr<T>(new typename
105         detail::up_element<T>::type[size]);
106 }
107
108 } /* boost */
109
110 #endif