Skip to content

Commit 07096be

Browse files
committed
GPU: Add some more type trait templates for GPU code
1 parent f44f236 commit 07096be

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

GPU/Common/GPUCommonTypeTraits.h

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <type_traits>
2323
#endif
2424
#else
25-
// We just reimplement some type traits in std for the GPU
25+
// We just reimplement some type traits in std for the GPU // TODO: Check if meanwhile we can get rid of GPUCommonTypeTraits and GPUCommonArray, and just use the std headers.
2626
namespace std
2727
{
2828
template <bool B, class T, class F>
@@ -35,6 +35,7 @@ struct conditional<false, T, F> {
3535
};
3636
template <bool B, class T, class F>
3737
using contitional_t = typename conditional<B, T, F>::type;
38+
3839
template <class T, class U>
3940
struct is_same {
4041
static constexpr bool value = false;
@@ -45,13 +46,15 @@ struct is_same<T, T> {
4546
};
4647
template <class T, class U>
4748
static constexpr bool is_same_v = is_same<T, U>::value;
49+
4850
template <bool B, class T = void>
4951
struct enable_if {
5052
};
5153
template <class T>
5254
struct enable_if<true, T> {
5355
typedef T type;
5456
};
57+
5558
template <class T>
5659
struct remove_cv {
5760
typedef T type;
@@ -68,6 +71,9 @@ template <class T>
6871
struct remove_cv<const volatile T> {
6972
typedef T type;
7073
};
74+
template <class T>
75+
using remove_cv_t = typename remove_cv<T>::type;
76+
7177
template <class T>
7278
struct remove_const {
7379
typedef T type;
@@ -76,6 +82,9 @@ template <class T>
7682
struct remove_const<const T> {
7783
typedef T type;
7884
};
85+
template <class T>
86+
using remove_const_t = typename remove_const<T>::type;
87+
7988
template <class T>
8089
struct remove_volatile {
8190
typedef T type;
@@ -84,6 +93,9 @@ template <class T>
8493
struct remove_volatile<volatile T> {
8594
typedef T type;
8695
};
96+
template <class T>
97+
using remove_volatile_t = typename remove_volatile<T>::type;
98+
8799
template <class T>
88100
struct is_pointer_t {
89101
static constexpr bool value = false;
@@ -95,6 +107,36 @@ struct is_pointer_t<T*> {
95107
template <class T>
96108
struct is_pointer : is_pointer_t<typename std::remove_cv<T>::type> {
97109
};
110+
111+
template <class T>
112+
struct remove_reference {
113+
typedef T type;
114+
};
115+
template <class T>
116+
struct remove_reference<T&> {
117+
typedef T type;
118+
};
119+
template <class T>
120+
struct remove_reference<T&&> {
121+
typedef T type;
122+
};
123+
template <class T>
124+
using remove_reference_t = typename remove_reference<T>::type;
125+
126+
template <class T>
127+
struct is_member_pointer_helper {
128+
static constexpr bool value = false;
129+
};
130+
template <class T, class U>
131+
struct is_member_pointer_helper<T U::*> {
132+
static constexpr bool value = true;
133+
};
134+
template <class T>
135+
struct is_member_pointer : is_member_pointer_helper<typename std::remove_cv<T>::type> {
136+
};
137+
template <class T>
138+
static constexpr bool is_member_pointer_v = is_member_pointer<T>::value;
139+
98140
} // namespace std
99141
#endif
100142

0 commit comments

Comments
 (0)