Nui
internal.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <utility>
4 
5 #ifndef __WRL_ASSERT__
6 # ifdef __WRL_CONFIGURATION_LEGACY__
7 // Take NT_ASSERT for windows build
8 # include <ntassert.h>
9 # define __WRL_ASSERT__(cond) NT_ASSERT(cond)
10 # else
11 // Take CRT assert as default
12 # include <crtdbg.h>
13 # define __WRL_ASSERT__(cond) _ASSERTE(cond)
14 # endif // BUILD_WINDOWS
15 #endif // __WRL_ASSERT__
16 
17 #ifndef __WRL_IMPLEMENTS_FTM_BASE__
18 # ifdef __WRL_CONFIGURATION_LEGACY__
19 # define __WRL_IMPLEMENTS_FTM_BASE__(flags) (false)
20 # else
21 # define __WRL_IMPLEMENTS_FTM_BASE__(flags) ((flags & ::Microsoft::WRL::InhibitFtmBase) == 0)
22 # endif
23 #endif
24 
25 #ifndef __WRL_CONFIGURATION_LEGACY__
26 # ifndef __WRL_STRICT__
27 // #define __WRL_STRICT__
28 # endif
29 #endif
30 
31 // Include common headers
32 #include <windows.h>
33 
34 // Helper types
35 namespace Microsoft
36 {
37  namespace WRL
38  {
39  namespace Details
40  {
41 
42  struct BoolStruct
43  {
44  int Member;
45  };
46 
47  typedef int BoolStruct::*BoolType;
48 
49  inline void RaiseException(HRESULT hr, DWORD dwExceptionFlags = EXCEPTION_NONCONTINUABLE)
50  {
51  ::RaiseException(static_cast<DWORD>(hr), dwExceptionFlags, 0, NULL);
52  }
53 
54  template <bool b, typename T = void>
55  struct EnableIf
56  {};
57 
58  template <typename T>
59  struct EnableIf<true, T>
60  {
61  typedef T type;
62  };
63 
64  template <typename T1, typename T2>
65  struct IsSame
66  {
67  static const bool value = false;
68  };
69 
70  template <typename T1>
71  struct IsSame<T1, T1>
72  {
73  static const bool value = true;
74  };
75 
76  template <class T>
78  {
79  typedef T Type;
80  };
81 
82  template <class T>
83  struct RemoveReference<T&>
84  {
85  typedef T Type;
86  };
87 
88  template <class T>
89  struct RemoveReference<T&&>
90  {
91  typedef T Type;
92  };
93 
94  template <class T>
95  inline typename RemoveReference<T>::Type&& Move(_Inout_ T&& arg) throw()
96  {
97  return std::move(arg);
98  }
99 
100  template <class T>
101  inline void Swap(_Inout_ T& left, _Inout_ T& right) throw()
102  {
103  T tmp = Move(left);
104  left = Move(right);
105  right = Move(tmp);
106  }
107 
108  // Disables template argument deduction from Forward helper
109  template <class T>
110  struct Identity
111  {
112  // Map T to type unchanged
113  typedef T Type;
114  };
115 
116  template <class T>
117  inline T&& Forward(typename Identity<T>::Type& arg) throw()
118  {
119  // Forward arg, given explicitly specified Type parameter
120  return std::forward<T>(arg);
121  }
122 
123  template <typename Base, typename Derived>
125  {
126  static const bool value = __is_base_of(Base, Derived);
127  };
128 
129  template <typename Base>
130  struct IsBaseOfStrict<Base, Base>
131  {
132  static const bool value = false;
133  };
134 
135  }
136  }
137 } // namespace Microsoft::WRL::Details
void RaiseException(HRESULT hr, DWORD dwExceptionFlags=EXCEPTION_NONCONTINUABLE)
Definition: internal.h:49
int BoolStruct::* BoolType
Definition: internal.h:47
void Swap(_Inout_ T &left, _Inout_ T &right)
Definition: internal.h:101
RemoveReference< T >::Type && Move(_Inout_ T &&arg)
Definition: internal.h:95
T && Forward(typename Identity< T >::Type &arg)
Definition: internal.h:117
This file has no copyright assigned and is placed in the Public Domain.
Definition: client.h:26
Definition: internal.h:43
int Member
Definition: internal.h:44
Definition: internal.h:56
Definition: internal.h:111
T Type
Definition: internal.h:113
Definition: internal.h:125
static const bool value
Definition: internal.h:126
Definition: internal.h:66
static const bool value
Definition: internal.h:67
T Type
Definition: internal.h:79