make_unique.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 
5 #if defined(_MSC_VER) && __cplusplus == 201103L
6 # define MAKE_UNIQUE_DEFINED 1
7 #endif
8 
9 #ifdef __cpp_lib_make_unique
10 # define MAKE_UNIQUE_DEFINED 1
11 #endif
12 
13 #ifndef MAKE_UNIQUE_DEFINED
14 
15 //The compiler doesn't provide it, so implement it ourselves.
16 
17 #include <cstddef>
18 #include <memory>
19 #include <type_traits>
20 #include <utility>
21 
22 namespace std {
23 
24 template<class _Ty> struct _Unique_if {
25  typedef unique_ptr<_Ty> _Single_object;
26 };
27 
28 template<class _Ty> struct _Unique_if<_Ty[]> {
29  typedef unique_ptr<_Ty[]> _Unknown_bound;
30 };
31 
32 template<class _Ty, size_t N> struct _Unique_if<_Ty[N]> {
33  typedef void _Known_bound;
34 };
35 
36 template<class _Ty, class... Args>
38 make_unique(Args&&... args) {
39  return unique_ptr<_Ty>(new _Ty(std::forward<Args>(args)...));
40 }
41 
42 template<class _Ty>
44 make_unique(size_t n) {
45  typedef typename remove_extent<_Ty>::type U;
46  return unique_ptr<_Ty>(new U[n]());
47 }
48 
49 
50 } // namespace std
51 
52 #endif // !COMPILER_SUPPORTS_MAKE_UNIQUE
53 
unique_ptr< _Ty[]> _Unknown_bound
Definition: make_unique.hpp:29
unique_ptr< _Ty > _Single_object
Definition: make_unique.hpp:25
Definition: any.hpp:455
_Unique_if< _Ty >::_Single_object make_unique(Args &&...args)
Definition: make_unique.hpp:38


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sat Jun 8 2019 18:04:05