Skip to content

Commit ae30095

Browse files
committed
enable_if && type_identity
1 parent a4f5ecb commit ae30095

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

include/nbl/builtin/hlsl/type_traits.hlsl

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
template<class T> struct add_pointer; (TODO)
103103
104104
// other transformations
105-
template<class T> struct type_identity; (TODO)
105+
template<class T> struct type_identity; (DONE)
106106
template<class T> struct remove_cvref; (TODO)
107107
template<class T> struct decay; (TODO)
108108
template<bool, class T = void> struct enable_if; (NOT-APPLICABLE)
@@ -302,6 +302,21 @@ struct is_compound : bool_constant<!is_fundamental<T>::value> {};
302302
template <class T>
303303
struct is_aggregate : is_compound<T> {};
304304

305+
template<class T>
306+
struct type_identity
307+
{
308+
using type = T;
309+
};
310+
311+
template<bool B, class T = void>
312+
struct enable_if {};
313+
314+
template<class T>
315+
struct enable_if<true, T>
316+
{
317+
using type = T;
318+
};
319+
305320
// need this crutch because we can't make `#define typeid` work both on expression and types
306321
template<typename T>
307322
struct typeid_t;
@@ -397,9 +412,15 @@ using is_compound = std::is_compound<T>;
397412
template<class T>
398413
using is_aggregate = std::is_aggregate<T>;
399414

415+
template<typename T>
416+
using type_identity = std::type_identity<T>;
417+
400418
template<typename T>
401419
struct typeid_t : std::integral_constant<uint64_t,typeid(T).hash_code()> {};
402420

421+
template<bool B, class T = void>
422+
using enable_if = std::enable_if<B, T>;
423+
403424
#endif
404425

405426
// Overlapping definitions

0 commit comments

Comments
 (0)