You.i Engine
YiPredefCXX11.h
Go to the documentation of this file.
1 // © You i Labs Inc. All rights reserved.
2 #ifndef _YI_PREDEF_CXX11_H_
3 #define _YI_PREDEF_CXX11_H_
4 
5 #include <cstddef>
6 #include <memory>
7 #include <type_traits>
8 
9 // Technically adding to the std namespace is undefined behaviour
10 namespace std
11 {
12 template<bool _Bp, class _Tp = void>
13 using enable_if_t = typename enable_if<_Bp, _Tp>::type;
14 
15 template<class _Tp>
16 using decay_t = typename decay<_Tp>::type;
17 
18 template<>
19 struct less<void>
20 {
21  template<class _T1, class _T2>
22  constexpr auto operator()(_T1 &&__t, _T2 &&__u) const
23  noexcept(noexcept(std::forward<_T1>(__t) < std::forward<_T2>(__u)))
24  -> decltype(std::forward<_T1>(__t) < std::forward<_T2>(__u))
25  {
26  return std::forward<_T1>(__t) < std::forward<_T2>(__u);
27  }
28  typedef void is_transparent;
29 };
30 
31 template<class _Tp>
33 {
34  typedef unique_ptr<_Tp> __unique_single;
35 };
36 
37 template<class _Tp>
38 struct __unique_if<_Tp[]>
39 {
40  typedef unique_ptr<_Tp[]> __unique_array_unknown_bound;
41 };
42 
43 template<class _Tp, size_t _Np>
44 struct __unique_if<_Tp[_Np]>
45 {
47 };
48 
49 template<class _Tp, class... _Args>
51 make_unique(_Args &&... __args)
52 {
53  return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...));
54 }
55 
56 template<class _Tp>
58 make_unique(size_t __n)
59 {
60  typedef typename remove_extent<_Tp>::type _Up;
61  return unique_ptr<_Tp>(new _Up[__n]());
62 }
63 
64 template<class _Tp, class... _Args>
66 make_unique(_Args &&...) = delete;
67 
68 } // namespace std
69 
70 #undef YI_CONSTEXPR
71 #undef YI_CONSTEXPR_IMPL
72 #define YI_CONSTEXPR
73 #define YI_CONSTEXPR_IMPL inline
74 
75 #endif // !_YI_PREDEF_CXX11_H_
__unique_if< _Tp >::__unique_single make_unique(_Args &&... __args)
Definition: YiPredefCXX11.h:51
typename enable_if< _Bp, _Tp >::type enable_if_t
Definition: YiPredefCXX11.h:13
constexpr auto operator()(_T1 &&__t, _T2 &&__u) const noexcept(noexcept(std::forward< _T1 >(__t)< std::forward< _T2 >(__u))) -> decltype(std::forward< _T1 >(__t)< std::forward< _T2 >(__u))
Definition: YiPredefCXX11.h:22
Definition: YiPredefCXX11.h:32
STL namespace.
typename decay< _Tp >::type decay_t
Definition: YiPredefCXX11.h:16
void __unique_array_known_bound
Definition: YiPredefCXX11.h:46
void is_transparent
Definition: YiPredefCXX11.h:28
unique_ptr< _Tp[]> __unique_array_unknown_bound
Definition: YiPredefCXX11.h:40
unique_ptr< _Tp > __unique_single
Definition: YiPredefCXX11.h:34